要创建测试文件,首先要在文件名中包含空白:
vim "/tmp/it is a test.txt"
bash escape
使用grep搜索:
grep -lr 'bash' /tmp
/tmp/it is a test.txt
我想在grep之后使用grep命令:
grep -lr 'bash' /tmp | xargs grep escape
grep: /tmp/it: No such file or directory
grep: is: No such file or directory
grep: a: No such file or directory
grep: test.txt: No such file or directory
所以我在xargs中添加了-0
:
grep -lr 'bash' /tmp | xargs -0 grep escape
grep: /tmp/it is a test.txt
: No such file or directory
我觉得原因是:
grep -lr 'bash' /tmp | xargs -0
grep: /tmp/it is a test.txt
#a blank line at the bottom
xargs -0
添加了一个空行!
如何抑制输出: No such file or directory
?
发布于 2022-05-13 13:45:08
grep
有-s
或--no-messages
选项,可以禁止有关不存在或无法读取的文件的错误消息。
https://stackoverflow.com/questions/70144684
复制相似问题