问题描述
我想获取我的应用程序中的行数.我正在使用此代码:
I want to get the number of lines in my application. I am using this code:
find . "(" -name "*.m" -or -name "*.h" ")" -print | xargs wc -l
在其他应用程序中它可以正常工作,但是对于我的一个应用程序,它给出了错误"xargs unterminated quote".
It is working fine in other applications but for one of my applications it is giving the error "xargs unterminated quote".
推荐答案
您的文件名之一是否带有引号?尝试这样的事情:
Does one of your filenames have a quote in it? Try something like this:
find . "(" -name "*.m" -or -name "*.h" ")" -print0 | xargs -0 wc -l
-print0
参数告诉find
使用NULL字符终止打印出的每个名称. -0
自变量告诉xargs
,其输入令牌是NULL终止的.这样可以避免出现字符问题,否则这些字符将被视为特殊字符,例如引号.
The -print0
argument tells find
to use the NULL character to terminate each name that it prints out. The -0
argument tells xargs
that its input tokens are NULL-terminated. This avoids issues with characters that otherwise would be treated as special, like quotes.
这篇关于得到错误"xargs终止报价".尝试在终端中打印行数时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!