Is there a way to do:
output | grep "string1" | grep "string2"
BUT with awk, WITHOUT PIPE?
Something like:
output | awk '/string1/ | /string2/ {print $XY}'
Result should be subset of matches, if tha makes sense.
Is there a way to do:
output | grep "string1" | grep "string2"
BUT with awk, WITHOUT PIPE?
Something like:
output | awk '/string1/ | /string2/ {print $XY}'
Result should be subset of matches, if tha makes sense.
The default action with awk is to print, so the equivalent of
output | grep string1 | grep string2
is
output | awk '/string1/ && /string2/'
e.g.
$ cat tst
foo
bar
foobar
barfoo
foothisbarbaz
otherstuff
$ cat tst | awk '/foo/ && /bar/'
foobar
barfoo
foothisbarbaz
If you want awk to find lines that match both string1 and string2, in any order, use &&:
output | awk '/string1/ && /string2/ {print $XY}'
If you want to match either string1 or string2 (or both), use ||:
output | awk '/string1/ || /string2/ {print $XY}'