I intend to run a shell command that outputs hundreds of lines that end with the word 'OK'. I want to store this output to a file and do not want all those lines that end with the 'OK'. How would I do this?
Something like command > output.txt --exclude_lines=*.OK
is what I was looking for.
CodePudding user response:
Assuming that the word OK
is supposed to be at the end of the line, you could do it by
your_command | grep -vw 'OK$' >output.txt
The $
ensures that an OK inside the line is ignored, and the -w
ensures that a line ending in i.e. NOK is not missed.