Bro*_*row 3 unix bash grep exec find
我想了解这一行:
find $HOME -name "*.c" -exec grep "find this string" {} /dev/null \;
Run Code Online (Sandbox Code Playgroud)
我理解其中的大部分,但我不确定/dev/null在{}之前和之后出现的情况;.
find找到每个C程序文件,然后为每个文件grep查找包含字符串的行...然后将所有错误发送到/dev/null?
它用于强制grep打印匹配的文件名,仅在没有特定选项的greps中有用.看:
$ cat file
1
2
3
$ grep 2 file
2
$ grep 2 file /dev/null
file:2
Run Code Online (Sandbox Code Playgroud)
过去需要获得输出但是使用GNU grep(以及其他?)这些天你可以这样做:
$ grep -H 2 file
file:2
Run Code Online (Sandbox Code Playgroud)
您可能想查看教科书上的销售日期;-).