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

grepping a stringd + 3 lines 1

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
IL
Hi,

I have a 10 MB text file,no space/special paragraph marks between the lines.

I need to grep out lines with a <string> and 3 lines after this line .

How will I do it ? &quot;Long live king Moshiach !&quot;
h
 
Here are two one line solutions.

sed -n '/grep/{$!N;$!N;$!N;p;}' < 10meg.file

awk '/grep/{print;for(i=0;i<3 && getline>0;i++) print;}' < 10meg.file

Cheers,
ND [smile]

bigoldbulldog@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top