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
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
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
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 '/asser_equal/&&!/amazon/' file