从linux终端在所有makefiles中搜索一个单词
我在用Ubuntu。我必须在多个makefile中搜索单词“send”。 假设所有makefile都位于/home/mypath中。我尝试了这个命令,但不起作用。你能帮帮我吗?提前谢谢从linux终端在所有makefiles中搜索一个单词,linux,shell,ubuntu,terminal,command,Linux,Shell,Ubuntu,Terminal,Command,我在用Ubuntu。我必须在多个makefile中搜索单词“send”。 假设所有makefile都位于/home/mypath中。我尝试了这个命令,但不起作用。你能帮帮我吗?提前谢谢 find /home/mypath/ -name Makefile && grep -r "send" 如果基本路径相同,则只能使用grep: grep -rn --color "send" /home/mypath/Makefile find命令有一个选项,可以将找到的文件名传输到exec
find /home/mypath/ -name Makefile && grep -r "send"
如果基本路径相同,则只能使用
grep
:
grep -rn --color "send" /home/mypath/Makefile
find
命令有一个选项,可以将找到的文件名传输到exec命令,此处为grep。重要的是,您给出的{}
将替换为find
找到的文件名。您还需要\
作为为find
的“-exec”选项指定的命令的结束标记
find /home/mypath -name Makefile -exec grep "what you search" {} \;
您可以使用下面的命令在所有
makefile
递归地
find /home/mypath -name "Makefile" | xargs grep -r "send"
这里的find
命令列出指定目录下名为Makefile
的所有文件xargs
命令将按顺序将列出的所有文件传递给grep
命令,以搜索字符串send