grep -E '(^[^B]*$|A)'
EDIT: Whoops, I meant to make this a top-level comment.
EDIT 2: On one client it looked like a nested comment and on this other client it looks top level and now I'm a confused old man.
grep -E '(^[^B]*$|A)'
EDIT: Whoops, I meant to make this a top-level comment.
EDIT 2: On one client it looked like a nested comment and on this other client it looks top level and now I'm a confused old man.
You don't need parentheses here.
~~How dare you?~~
Thanks!
Haha, on Lemmy.World it looks like a top level. Thank you, either way :)
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, then awk '!/B/ || (/A/ && /B/)'
will work.
Thank you! This was exactly was I was looking for. :)