I want to grep files that contain text "wp_" but do not contain text "wp3_". E.g. I’ve got a file with two strings:
wp_123
wp3_123
I try $ grep -lr wp_ ~/tmp | xargs grep -vl wp3_
It outputs this file name! But if I remove the linebreak, it’s working like I want, i.e. handles string "wp_123 wp3_123" correctly.
How to make it work with search conditions on different strings?
P.S. Sorry for kind of duplicate, but seems that nobody noticed my comment during last hour…
This should work
The single quotes are not necessary in this case, but are a good habit to prevent pattern characters from being interpreted by the shell. In your original attempt, -vl means “print each file with at least one line that does not match”. Here, -L means “print each file with no lines that match”.