Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Removing \n from a text file

$
0
0
Hi All,

I have a question regarding text substitution.
I have a file that contains a lot of text.
Some of the text is separated with a \n like:

Code:

TEST\nTEST2\nTEST3
BLA\nBLA2\nBLA3

So there are both actual newlines and 'used to be newlines' in the text.

using tr
Code:

tr "\n" ","
or using sed
Code:

sed 's/\n/,/'
I get the same result: They both replace all the actual newlines in the text file with a comma but NONE of the \n in the file get replaced...

I would like to have the reverse. I would like to keep the newlines and replace any \n in the file with a comma.

Does anyone have an idea?

Viewing all articles
Browse latest Browse all 16232

Trending Articles