xargs 不工作
我想要所有带有assert_equal并且没有amazon的行。
我尝试跟随但它不起作用。
ack assert_equal | xargs ack -v amazon
I want all the lines with assert_equal and without amazon.
I tried following but it is not working.
ack assert_equal | xargs ack -v amazon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你不需要 xargs:
You don't need xargs:
您的命令似乎存在一些问题。在第一部分中:
您没有提供文件名,因此 ack 没有任何需要处理的内容。在第二部分中:
您正在使用
xargs
将初始ack
的结果作为命令行参数提供给第二个ack
,即可能不是你想要的。ack
已设计为接受标准输入数据,因此您根本不需要使用xargs
。这是一个应该更有效的声明:
或者,如果您从另一个命令获取输出,例如:
There seem to be a couple of problems with your command. In the first part:
you do not provide a filename, so
ack
has nothing to process. In the second part:you are using
xargs
to provide the results from the initialack
as command-line arguments to the secondack
, which is probably not what you intended.ack
is already designed to accept data on standard input, so you do not need to usexargs
at all.Here is a statement that should work better:
or, if you are getting the output from another command, something like:
这段代码应该能让您了解您需要做什么。神奇之处在于 -print0 选项。不是直接的解决方案;我感觉很懒。
this snippet should give you an idea as to what you need to do. The magic is in the -print0 option. Not a direct solution; i'm feeling lazy.
ack
不是 *nix 中的标准工具。既然你有了它,就可以了。但如果您使用的是没有它的 *nix 系统,请按照以下方法操作ack
is not a standard tool in *nix. since you have it, its ok. But if you are on a *nix system which doesn't have it, here's how you can do it