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

Can I use sed to insert the newline (\n) character .....

Status
Not open for further replies.

dsearfass

Programmer
Jan 23, 2002
2
0
0
US
I have a file ...
Each line looks something like the following:
13212121 NEWLINE 121211 11112121 12121

What I want to do is replace the text 'NEWLINE' with the
actual newline \n character.

So my output will now look like:
13212121
121211 11112121 12121

I thought sed would be the best tool to use for this but
there could be a better alternative.

I don't want to do this through interactive VI. I want to
be able to place this in a KSH script.

Thanks ahead of time for any help,
It's much appreciated.

-dave
 
To do this in sed I would write a tiny sed script like this

>cat tiny.sd
s-NEWLINE--

There is literally a new line character at the end of the first line. Then to invoke it in the KSH script do the following

sed -f tiny.sd file > newfile

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top