Linux-grep 命令和find 命令 (6)
2017-07-13 15:18
751 查看
grep与find区别:
grep:查找指定目录下过滤文本文件中行数据
find:查找指定目录下文件
[b]grep使用[/b]
格式: grep "text" * [选项]
选项:
-A num, --after-context=num: 在结果中同时输出匹配行之后的num行
-B num, --before-context=num: 在结果中同时输出匹配行之前的num行,有时候我们需要显示几行上下文。
-i, --ignore-case: 忽略大小写
-n, --line-number: 显示行号
-R, -r, --recursive: 递归搜索子目录
-v, --invert-match: 输出没有匹配的行
-w :只显示全字符合的列,例如搜索"CONFIG_DM9000",就不会出现"CONFIG_DM9000_BASE"字段
-x :只显示全列符合的列
实例:
如下图所示:
![](https://images2015.cnblogs.com/blog/1182576/201707/1182576-20170713151705790-934583499.png)
[b]find使用[/b]
格式: find [选项] text
常用选项:
-name : 查找文件名
实例:
grep:查找指定目录下过滤文本文件中行数据
find:查找指定目录下文件
[b]grep使用[/b]
格式: grep "text" * [选项]
选项:
-A num, --after-context=num: 在结果中同时输出匹配行之后的num行
-B num, --before-context=num: 在结果中同时输出匹配行之前的num行,有时候我们需要显示几行上下文。
-i, --ignore-case: 忽略大小写
-n, --line-number: 显示行号
-R, -r, --recursive: 递归搜索子目录
-v, --invert-match: 输出没有匹配的行
-w :只显示全字符合的列,例如搜索"CONFIG_DM9000",就不会出现"CONFIG_DM9000_BASE"字段
-x :只显示全列符合的列
实例:
grep "33F80000" * -nR //递归地查找当前目录下所有文件中带"33F80000"行的数据,并显示出来
如下图所示:
![](https://images2015.cnblogs.com/blog/1182576/201707/1182576-20170713151705790-934583499.png)
grep "\-pie" * -nR //递归查找当前目录下所有文件,带有"-pie"一行的代码
[b]find使用[/b]
格式: find [选项] text
常用选项:
-name : 查找文件名
实例:
find -name Makefile //查找当前目录下Makefile文件 find /work -name start.c //查找指定目录/work/下start.c文件 find -name boot* //查找当前目录下带boot开头的所有文件(就能找到boot.c,boot.o,boot.bin等) find -name *boot //查找当前目录下名字中带有boot的所有文件 ,*:表示通配符,*boot就是通配所有包含boot的内容 find -name *.c //查找当前目录下所有.c文件
相关文章推荐
- linux查找命令、find、grep
- linux下的find文件查找命令与grep文件内容查找命令
- linux下的find文件查找命令与grep文件内容查找命令
- linux下的find文件查找命令与grep文件内容查找命令
- Linux下的五个查找命令:grep、find、locate、whereis、which
- linux中强大且常用命令:find、grep
- linux命令 find、grep
- Linux find、grep命令详细用法
- Linux中的find、grep命令
- 【亲测】linux命令 - find, grep
- Linux 常用命令1 pwd、ls、cd、tab、清屏、重定向、转义、管道、touch、mkdir、tree、cat、more、rmdir、rm、grep、help、man、history、find
- linux下的find文件查找命令与grep文件内容查找命令
- linux中强大且常用命令:find、grep
- linux之find、grep命令简要理解
- linux -- Linux下的五个查找命令:grep、find、locate、whereis、which
- linux中强大且常用命令:find、grep
- linux中强大且常用命令:find、xargs、grep
- linux下的find文件查找命令与grep文件内容查找命令
- Linux命令温故而知新:find and grep
- Linux中find、grep命令详细用法