开发者

xargs not working

I want all the lines with assert_equal and without amazon.

I tried following but it is not 开发者_如何学Pythonworking.

ack assert_equal | xargs ack -v amazon


You don't need xargs:

ack assert_equal | ack -v amazon


There seem to be a couple of problems with your command. In the first part:

ack assert_equal

you do not provide a filename, so ack has nothing to process. In the second part:

xargs ack -v amazon

you are using xargs to provide the results from the initial ack as command-line arguments to the second ack, which is probably not what you intended. ack is already designed to accept data on standard input, so you do not need to use xargs at all.

Here is a statement that should work better:

ack assert_equal filename | ack -v amazon

or, if you are getting the output from another command, something like:

my_command | ack assert_equal | ack -v amazon


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 -f --print0 --php -G 'scripts' --invert-file-match|xargs -0 ls -l


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

awk '/assert_equal/&&!/amazon/' file
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜