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!

How to delete data before a particular word in UNIX

Status
Not open for further replies.

sarwar71

Programmer
Jun 19, 2007
3
US
Hi all,

Hoping that you guys are doing great. I have a question that "How to delete text before a particaulr word from a text filein UNIX"

Actually, I wrote a unix script that generate files from the database and it also has some header information on top of every file. I like to disregard all the information before a particular word i.e "CREATE".

Can someone help me in writing the code to meet the above requirement?

Thanks,

Sarwar
 
One way with sed:
sed -n 's!.*CREATE!CREATE!;/CREATE/,$p' /path/to/input > output

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you very much!!!

It works like a charm...


Thanks,

Sarwar
 
Actually, I am new with SED, can you please explain your command in plain english so that I can understand what exactly you did.


Thanks,

Sarwar
 
man sed

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top