سؤال

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

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

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top