Is there any way to use grep
to search for entry matching multiple patterns in any order using single condidion?
As showed in How to run grep with multiple AND patterns? for multiple patterns i can use
grep -e 'foo.*bar' -e 'bar.*foo'
but i have to write 2 conditions here, 6 conditions for 3 patterns and so on... I want to write single condition if possible. For finding patterns in any order you can suggest to use:
grep -e 'foo' | grep -e 'bar' # at least i do not retype patterns here
and this will work but i would like to see colored output and in this case only bar will be highlighted.
I would like to write condition as easy as
awk '/foo/ && /bar/'
if it is possible for grep
(awk does not highlight results and i doubt it can be done easily).
agrep
can probably do what i want, but i wonder if my default grep (2.10-1) on ubuntu 12.04 can do this.
Aucun commentaire:
Enregistrer un commentaire