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

blank line ( beginer )

Status
Not open for further replies.

paijo

Technical User
Apr 13, 2005
4
NG
Hi guys
can you help me ?
I have file format like this :

new york
kanada

china
USA
denmark

nairobi
kenya
bali

black
green
dark
blue

I want to find the word kenya then I want to get the result :
china
USA
denmark

nairobi
kenya
bali

black
green
dark
blue


So every time I found, special word that I am looking for then it will print group lines before and after the group lines that contain that word.

I am using UNIX awk for this case

thanks alot

paijo
 
With the GNU grep you may play with the -A and -B options.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
in AIX you can print stanza using grep command, for example:

grep -p kenya filename


you would get:

nairobi
kenya
bali
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top