File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ _krb_kadmin:*:231:-2:Open Directory Kerberos Admin Service:/var/empty:/usr/bin/f
2121$ grep -FR ' someVar' .
2222```
2323
24- 別忘了大小不敏感的参数,因为 grep 默认搜索是大小写敏感的。
24+ 別忘了大小不敏感的参数,因为 ` grep ` 默认搜索是大小写敏感的。
2525
2626``` bash
2727$ grep -iR ' somevar' .
@@ -33,21 +33,21 @@ $ grep -iR 'somevar' .
3333$ grep -lR ' somevar' .
3434```
3535
36- 如果你写的脚本或批处理任务需要上面的输出内容,可以使用 while 和 read 来处理文件名中的空格和其他特殊字符:
36+ 如果你写的脚本或批处理任务需要上面的输出内容,可以使用 ` while ` 和 ` read ` 来处理文件名中的空格和其他特殊字符:
3737
3838``` bash
3939grep -lR someVar | while IFS= read -r file; do
4040 head " $file "
4141done
4242```
4343
44- 如果你在你的项目里使用了版本控制软件,它通常会在 .svn, .git, .hg 目录下包含一些元数据。你也可以很容易地用 grep -v 把这些目录移出搜索范围,当然得用 grep -F 指定一个恰当且确定的字符串,即要移除的目录名:
44+ 如果你在你的项目里使用了版本控制软件,它通常会在 ` .svn ` , ` .git ` , ` .hg ` 目录下包含一些元数据。你也可以很容易地用 ` grep -v ` 把这些目录移出搜索范围,当然得用 ` grep -F ` 指定一个恰当且确定的字符串,即要移除的目录名:
4545
4646``` bash
4747$ grep -R ' someVar' . | grep -vF ' .svn'
4848```
4949
50- 部分版本的 grep 包含了 --exclude 和 --exclude-dir 选项,这看起来更加易读。
50+ 部分版本的 ` grep ` 包含了 ` --exclude ` 和 ` --exclude-dir ` 选项,这看起来更加易读。
5151
5252## 参数
5353
You can’t perform that action at this time.
0 commit comments