Skip to content

Instantly share code, notes, and snippets.

@kevinhooke
Created December 13, 2015 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinhooke/fc1a6a49547d55ff9f44 to your computer and use it in GitHub Desktop.
Save kevinhooke/fc1a6a49547d55ff9f44 to your computer and use it in GitHub Desktop.
bash script - find files matching pattern, grep file content for pattern, pipe results to file
#!/bin/bash
for f in $(find -E . -regex ".*ext1|.*ext2|.*ext3")
do
echo $f $'\n' $(egrep -o 'TextAtStartOfLine:[[:space:]]*[[:digit:]]+' $f) $'\n' >> report"$(date)".txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment