Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从linux终端在所有makefiles中搜索一个单词_Linux_Shell_Ubuntu_Terminal_Command - Fatal编程技术网

从linux终端在所有makefiles中搜索一个单词

从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

我在用Ubuntu。我必须在多个makefile中搜索单词“send”。 假设所有makefile都位于/home/mypath中。我尝试了这个命令,但不起作用。你能帮帮我吗?提前谢谢

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