[英]Use command grep and locate
How I can make the grep command locate certain words in the files specified by the routes found by the locate command? 如何使grep命令在locate命令找到的路由指定的文件中找到某些单词?
locate my.cnf | grep user
(I want that grep command search the word "user" on the files found for locate command) (我希望grep命令在找到locate命令的文件中搜索单词“user”)
尝试:
locate my.cnf | xargs grep user
使用命令替换而不是管道:
grep user `locate my.cnf`
如果我正确理解你的问题,可能grep user $(locate my.cnf)
就是你要找的东西。
为了在定位结果在名称中包含空格的情况下玩得很好,您可以这样做
locate -0 my.cnf | xargs -n1 -0 grep user
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.