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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pirnt all lines except an especific line 1

Status
Not open for further replies.

rossyeperez

Technical User
Feb 1, 2007
15
MX
I have the following kind of file :

HOLA
XXXX
YYYY
XXXX
YYYY
XXXX
YYYY
HOLA xxx yyy xxx yyy xxx
1 2 3 4 5 6 7 8
2 3 4 5 6 7 8 9
3 2 1 3 5 6 7 8
4 5 4 2 3 1 3 4

I would like to print all lines with
all information include the first line HOLA without the
line witht the second "HOLA" --->HOLA xxx yyy xxx yyy xxx

HOLA
XXXX
YYYY
XXXX
YYYY
XXXX
YYYY
1 2 3 4 5 6 7 8
2 3 4 5 6 7 8 9
3 2 1 3 5 6 7 8
4 5 4 2 3 1 3 4



 
Hi

Code:
[gray]# to exclude the second line which has HOLA[/gray]
awk '/^HOLA/{if(++h==2)next}1' /input/file

[gray]# to exclude with lines with HOLA and trailing stuff[/gray]
awk '/^HOLA/&&NF>1{next}1' /input/file

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top