replace newline in text file

Bash shell is the common linux command language.
Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

replace newline in text file

Post by mister_v »

Hi,

how do I replace all the newline characters (\n) in a text file?
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: replace newline in text file

Post by chris »

You can use sed

replace it with FOO:

Code: Select all

sed '{:q;N;s/\n/FOO/g;t q}' /path/text.txt
or just remove it:

Code: Select all

sed '{:q;N;s/\n//g;t q}' /path/text.txt
Post Reply