Do you want to test whether both of two test strings are present at once, or whether either string is present? I'll show you how.



Either A or B:

$ cat -f filename | grep -P "\b(first|second)\b

Both A and B:
$ cat -f filename | grep -P "\bfirst\b" | grep -P "\bsecond\b"
Or you can use awk

$ cat -f filename | awk '/coloawap/&&/jar/{print $0}'

Leave a Reply