this post was submitted on 15 Feb 2024
16 points (94.4% liked)
commandline
1745 readers
1 users here now
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I like to use awk instead of grep wherever possible, especially for weird logic like this.
awk '!/B/ || /A.*B/'
is one way to skin that cat. If you don't care what order A and B are in on the lines containing both, thenawk '!/B/ || (/A/ && /B/)'
will work.Thank you! This was exactly was I was looking for. :)