So, a little help if any one can.
I have a file which contains for example
testA
cat
testB
1
testC
cat
testD
dog
i need to search through this file, and display testX only if it DOESNT have the word cat beneath it.
so, the logic would be cat file | grep -v -B1 cat >>output.txt
now i know this doesnt work, but i need something similar.
I cant search the other way round, because the words under testX change or arent there at all. The only constant is the word cat.
So i need to search for the word cat, and then exclude the line above it.
Any help would be massively appreciated!
I have a file which contains for example
testA
cat
testB
1
testC
cat
testD
dog
i need to search through this file, and display testX only if it DOESNT have the word cat beneath it.
so, the logic would be cat file | grep -v -B1 cat >>output.txt
now i know this doesnt work, but i need something similar.
I cant search the other way round, because the words under testX change or arent there at all. The only constant is the word cat.
So i need to search for the word cat, and then exclude the line above it.
Any help would be massively appreciated!