Page 1 of 1

replace newline in text file

Posted: Sun May 16, 2021 8:00 am
by mister_v
Hi,

how do I replace all the newline characters (\n) in a text file?

Re: replace newline in text file

Posted: Sun May 16, 2021 8:15 am
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