得到错误"xargs终止报价".尝试在终端中打印行数时 [英] Getting error "xargs unterminated quote" when tried to print the number of lines in terminal

查看:173
本文介绍了得到错误"xargs终止报价".尝试在终端中打印行数时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取我的应用程序中的行数.我正在使用此代码:

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终止报价".尝试在终端中打印行数时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆