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