Skip to content

Instantly share code, notes, and snippets.

@timhodson
Created April 4, 2012 15:08
Show Gist options
  • Save timhodson/2302411 to your computer and use it in GitHub Desktop.
Save timhodson/2302411 to your computer and use it in GitHub Desktop.
loop through files and feed contents to a script to process them
# where patterns are in files numbered like pattern_file_01.txt
for pattern in `ls pattern_file_??.txt`
do
STRING=`cat $pattern`
php -f myCleverScipt.php -- $STRING
done
# where patterns are single lines of a single file
while read line
do
# do something with the line here
done << myFileOfPatterns.txt
# one line - do not put semicolon after do
while read line ;do echo $line ; othercmd ; sleep 4 ; done << myFileOfPatterns.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment