Skip to content

Instantly share code, notes, and snippets.

@composite
Created October 18, 2018 02:07
Show Gist options
  • Select an option

  • Save composite/8ca0bdbb2f9c14782f3485dc781883df to your computer and use it in GitHub Desktop.

Select an option

Save composite/8ca0bdbb2f9c14782f3485dc781883df to your computer and use it in GitHub Desktop.
File files utility on UNIX
#!/bin/sh
#GREP for gz
find /path/to/folder -name '*.log.gz' -print0 | xargs -0 zgrep "STRING"
#GREP for log
find /path/to/folder -name '*.log' -print0 | xargs -0 grep "STRING"
#GREP regex
tail -f /path/to/something.log | egrep "Exception|\[WARN|\[ERROR"
#find files with file name pattern and content and print all matched file content.
find /path/to/folder -name '*.txt' -print0 | xargs -0 grep "STRING" -l | xargs cat && echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment