Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to print lines which do NOT match regex and their next lines?

Status
Not open for further replies.

jdhahbi

Technical User
Oct 7, 2009
24
US
Hi
I have a data file that looks like this:
infile:
Code:
A 
13
B 
23
F
22
B 
413
R 
16
I would like to print the lines that don't match 'Z' and their next lines?

the outfile should be:
Code:
A 
13
F
22
R 
16
I tried:
Code:
awk '!/Z/{print;getline;print}' infile
the out file looks the same as the infile
 
I am sorry, the correct infile is
Code:
A
13
Z
23
F
22
Z
413
R
16
 
awk '!/Z/{print;getline;print}/Z/{getline}' infile

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you very much. That is what I need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top