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 split line depending on pattern

Status
Not open for further replies.

kat000003

Technical User
Jan 27, 2005
37
CH
I have a file with a line > 2048.
I want to insert a newline on every occurance of a given pattern.
EG
For every occurance of AND , WHERE , FROM in my file
Do "insert newline"
write to new file
 
A starting point:
nawk '{gsub(/ AND | WHERE | FROM /,"\n&");print}' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top