Find command. How to process founded files to gunzip and then to grep by pattern

147 Views Asked by At

Example:

find . -name 'audit_log*.gz' -print -exec gunzip -c {} \| grep IP  \;

Need to add a key to this to get: -file name. -list IP from audit_log*.gz files.

1

There are 1 best solutions below

4
sto.vyshnavlal On BEST ANSWER

You've used the semi-column incorrectly. It should be at the end of the find command and before the pipe. Try this one-liner:

find . -type f -iname 'audit_log*.gz' -exec gunzip -c {} \; | grep IP