When doing command line thingys, sed allows one to do really cool stuff like:
sed 's/^something/something else/' | sed 's/^morestuff$/othermorestuff/'
sed -e 's/^something/something else/' -e 's/morestuff$/othermorestuff/'
The Short way speeds up multiple changes by eliminating the pipe (which creates natural overhead).
So, now having said this, is there a way to do this with grep?
For example, what I would like to do is (in the Linux kernel code):
grep --color -rI kmalloc . | grep -v return | grep -v '=[<space><tab>]*kmalloc' . . .
but in one line.
No way to do this in grep to my knowledge, except by enclosing the inner grep in "quotes and backticks" and as long as the outer grep only returns one result.
Because of the way quotes and backticks are handled, it's possible this doesn't work outside bash. It's also impossible to my knowledge to enclose a third grep.
grep -e "`grep args`" args
EDIT: changed "inner" to "outer" grep on the first line. The inner grep can return more than one result, of course (just tested it in any case). It's the outer grep that can't. Only the first result will be handled.
Yeah, I already "knew" that, but I was hoping I had missed something. ;)