سؤال

locate 'filename' | grep 'pattern' locates files then greps their file names. I want to grep the contents of the file instead.

هل كانت مفيدة؟

المحلول

you have to pass the filenames as arguments to grep:

grep 'pattern' $(locate 'filename')

(the $(...) will evaluate the command and return it's stdoutput)

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