Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.5k
  • 205
  • 1.8k
  • 2.3k
Tweeted twitter.com/#!/StackUnix/status/583766136191352832
Source Link
Sas
  • 1.1k
  • 3
  • 17
  • 23

How to replace a word with new line

I have a text file with following data and each row ends with |END|.

T|somthing|something|END|T|something2|something2|END|

I am tryig to replace |END| with \n new line with sed.

 sed 's/\|END\|/\n/g' test.txt

But it's producing wrong output like below:

 T
 |
 s
 o
 m
 e
 ...

But what I want is this:

T|somthing|something
T|something2|something2

I also tried with tr. It didn't work either.