find和区别grep的区别
你可以简单的理解为:
find查文件名
grep查文件内容
以下内容以具体例子说明,命令详解的文章,我会贴出,记住具体的例子会更容易一些,需要其它的用man 命令名 查一下即可
(70条消息) Linux 下的帮助命令_Alex_McAvoy的博客-优快云博客_linux命令帮助
1、用find按名字查找文件
find path -name filename
举例:查找名字为home/hello目录下world.txt的文件
用绝对路径:
find /home/hello -name world.txt
用相对路径假设当前目录在home:
find hello -name world.txt
Linux/Unix重要find命令详解 | 《Linux就该这么学》 (linuxprobe.com)
2、用grep查找文件内容
grep pattern file
查一个文件的内容:
举例:在当前目录下的world.txt中查找有hello“字样的”(pattern)的行
grep hello world.txt
加参数:
显示行号:
grep -n hello world.txt
查多个文件的内容:
grep -r pattern directory
以递归(-r)的方式,查找指定目录(directory)及其子目录下的所有文件,将含有指定“字样”(pattern)的所在行打印出来
例如:在/usr/include目录下查找含有 hello 字样的行,并且带有行号
grep -rn hello usr/include
Linux grep 命令 | 菜鸟教程 (runoob.com)
(70条消息) 【Linux命令】 grep命令基本用法_successdm的博客-优快云博客_linux命令grep用法