I've got a text file, and I want to search for lines that have search_string but do not have exclude_string.
In terminal, the following gives me the output I want:
grep "search_string" | grep -v "\(exclude_string_A\|exclude_string_B\)"
I have a bash script which scans text files for particular issues (mostly using grep and sed), and I'd like to add this search to it, but I can't seem to make it work. It doesn't seem like the output of the first grep command is being used as the input for the second.
For example, for a file containing:
Gary: yes, that's what I said. Paul: well, I didn't hear you. Gary: okay, let's go.
In the bash script, the relevant line is:
grep "Gary:" | grep -v "\(said\|told\)" $1
But the output file contains for that section:
Paul: well, I didn't hear you. Gary: okay, let's go.
I hope there's something simple I'm missing here!