当我将文件名传递给带有xargs的grep时,grep: : No such file or directory从何而来?
⋊> ~/.v/bundle find . -name config | grep ".git" | xargs grep "url" {} 11:07:46
grep: : No such file or directory
./Dockerfile.vim/.git/config: url = https://github.com/ekalinin/Dockerfile.vim.git
./nerdcommenter/.git/config: url = https://github.com/scrooloose/nerdcommenter.git虽然我没有空行之类的东西
⋊> ~/.v/bundle find . -name config | grep ".git" 11:08:30
./Dockerfile.vim/.git/config
./nerdcommenter/.git/config如何避免呢?
我知道我可以跳过像awk 'NR>1'这样的第一行,但是我想了解问题的原因。
谢谢。
P.S.我在麦克身上。
发布于 2016-03-10 11:32:55
不需要添加{} (与find -exec不同)
~/.v/bundle find . -name config | grep ".git" | xargs grep "url" 应该行得通。
或者更好(只是在文件或目录名称中包含空格或不寻常的字符):
~/.v/bundle find . -name config -print0 | grep -z ".git" | xargs --null grep "url"发布于 2016-03-10 11:36:05
很难说出你的网站出了什么问题。我尝试复制这个错误,也有.vim/bundle,但是我无法重现它。
无论如何,我建议将命令简化为:
find . -wholename '*/.git/config' -exec grep -H url {} +xargs不再是必需的,因为find支持+语法。至少对于GNU (MacOS)和find的busybox版本是这样的。
https://stackoverflow.com/questions/35914966
复制相似问题