Search code examples
linuxgrepfindexecgunzip

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


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.


Solution

  • 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