I am trying to run grep against a list of a few hundred files:$ head -n 3 <(cat files.txt)admin.phpajax/accept.phpajax/add_note.phpHowever, even though I am grepping for a string that I know is found in the files, the following does not search the files:$ grep -i 'foo' <(cat files.txt)$ grep -i 'foo' admin.phpThe foo was foundI am familiar with the -f flag which will read the patterns from a file. But how to read the input files?I had considered the horrible workaround of copying the files to a temporary directory as cp seems to support the <(cat files.txt) format, and from there grepping the files. Shirley there is a better way.
grep files from list
bash;grep;command substitution;process substitution
You seem to be grepping the list of filenames, not the files themselves. <(cat files.txt) just lists the files. Try <(cat $(cat files.txt)) to actually concatenate them and search them as a single stream, orgrep -i 'foo' $(cat files.txt)to give grep all the files.However, if there are too many files on the list, you may have problems with number of arguments. In that case I'd just writewhile read filename; do grep -Hi 'foo' $filename; done < files.txt