Created
December 13, 2015 22:55
-
-
Save kevinhooke/5c0a48c57afe4dba6919 to your computer and use it in GitHub Desktop.
bash script - find files matching filename pattern, search first line for matching pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for f in `find -E . -regex ".*ext1|.*ext2|.*ext3"` | |
do | |
line=$(head -n 1 $f) | |
if [[ $line =~ TextAtStartOfLine:[[:space:]]*([[:digit:]]+) ]]; then | |
echo "${BASH_REMATCH[0]}" # print whole match | |
echo "${BASH_REMATCH[1]}" # print 1st group match | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment