I have a list like the following:
Name_JR_1
1.1.1.1
Name_SR_1
2.2.2.2
Name_NONE_1
3.3.3.3
If I want to chose all associated name with following numerical syntax I can look for a pattern and print the matching line plus the after context or next line using the -A1
option, as follows:
grep "JR" -A1 file_name
and this will print what I want:
Name_JR_1
1.1.1.1
I need a way to invert this however, where I can REMOVE all entries which match the search pattern. However using the -v
option with this syntax doesen't give me the results I want:
grep -v "JR" -A1 file_name
What I want the output to be like after this command is as follows:
Names_SR_1
2.2.2.2
Name_NONE_1
3.3.3.3.