16

I have a list containing a set of tags, and would like to exclude one tag, unless another tag exists in the line.

Say I have the following list, and want to exclude B, unless A is present.

[A,B]
[A,C]
[B,C]
[A]
[B]

I can reverse grep for B:

> grep --invert-match "B"
[A,C]
[A]

How can I find the previous list, but also the item containing [A,B]?

you are viewing a single comment's thread
view the rest of the comments
[-] bizdelnick@lemmy.ml 1 points 4 months ago

You don't need parentheses here.

[-] Andy@programming.dev 1 points 4 months ago

~~How dare you?~~

Thanks!

this post was submitted on 15 Feb 2024
16 points (94.4% liked)

commandline

1601 readers
13 users here now

founded 1 year ago
MODERATORS