|
foreach question
OK, so I am extremely rusty and am just getting back to Unix after 9 years.
I'm stuck on something easy. I want to search line-by-line for a string in a file, and I want to do this to a series of files in a directory.
This works fine to do the search:
while read i; do grep $i file2; done <file1.txt
This also works fine to read a directory:
foreach file ('/bin/ls *.txt')
echo $file
end
but if I try and combine the two, no joy.
foreach file ('/bin/ls *.txt')
while read i; do grep $i file2; done <$file
end
Help please!
|