Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.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 查找包含特定文本的路径_Linux_Unix - Fatal编程技术网

Linux 查找包含特定文本的路径

Linux 查找包含特定文本的路径,linux,unix,Linux,Unix,如何从特定目录中找到包含字符串“tomcat”的所有路径? i、 我想找到任何包含tomcat1、tomcat2、tomcat3等的内容 谢谢。使用查找: find / -name "tomcat*" 试一试 将点替换为要搜索的目录,或将cd替换为要搜索的目录 如果您只想搜索目录名,请尝试 find . -type d -iname tomcat\* 请尝试grep grep -r "tomcat" dir 如果没有上下文,这里的其他答案可能会有点混乱。简短的回答是查看手册页,查找但我可以

如何从特定目录中找到包含字符串“tomcat”的所有路径? i、 我想找到任何包含tomcat1、tomcat2、tomcat3等的内容

谢谢。

使用查找:

find / -name "tomcat*"
试一试

将点替换为要搜索的目录,或将cd替换为要搜索的目录

如果您只想搜索目录名,请尝试

find . -type d -iname tomcat\*
请尝试grep

grep -r "tomcat" dir

如果没有上下文,这里的其他答案可能会有点混乱。简短的回答是查看手册页,查找
但我可以在这里添加一些摘要。基本上你想要:

find <starting path> -iname "tomcat*"
find-iname“tomcat*”
如果需要区分大小写,可以将
-iname
更改为
-name
。如果只想在当前目录和更低的目录中搜索,则应使用
作为起始目录。如果要搜索整个文件系统,请使用
/
。如果您想在tomcast中使用任何文件名,即使它位于文件的后面,也可以使用
“*tomcat*”
。您只需找出适合您搜索的内容。

使用Linux find(GNU findutils)4.7,尝试
-wholename
测试:

find-wholename*/tomcat*


find-键入d-wholename*/tomcat*

我可能还应该提到,这个问题对于SO来说可能是离题的,对于超级用户来说可能更好。+1用于汇编其他答案的要点并给出简洁的解释。
find <starting path> -iname "tomcat*"