xargs -0 -n 1 grep search-string < foo.txt
# -0 to handle filenames with spaces
# -n 1 means process a single file at a time
How can I make ack search through a list of files listed in a text file?
سؤال
I have foo.txt that contains a list of file names, delimited by newline. What I want to do is to use ack to search through the files listed in the foo.txt. How can I do that?
المحلول 2
نصائح أخرى
With ack 2.0 and the new -x
option, you can do this
cat foo.txt | ack -x search-string
Try doing this:
$ ack foo file
foo
Pipe it through to the files from list:
cat listoffiles.txt | ack -i searchstring --files-from=-
Following Andy's comment below, after testing to make sure it does work, the best answer is actually:
ack -i searchstring --files-from=listoffiles.txt
لا تنتمي إلى StackOverflow