mardi 13 janvier 2015

grep files from list


I am trying to run grep against a list of a few hundred files:



$ head -n 3 <(cat files.txt)
admin.php
ajax/accept.php
ajax/add_note.php


However, 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.php
The foo was found


I 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.



Aucun commentaire:

Enregistrer un commentaire