Reputation: 11
We receive a file which is essentially an ssh token key. This upon inception has values, say
Foo\nBarFoo,\nFoo\nBarFoo
Now, I want to replace these with
Foo
BarFoo,
Foo
BarFoo
I have tried sed
and tr
commands by copying the entire key in a variable.
One thing that seemed to work was : %s/\\n/\r/g
, but this is not acceptable since I cannot open the vi
editor.
I recently tried echo -e 'Foo\nBarFoo,\nFoo\nBarFoo
, but want to be it more subtle.
Upvotes: 1
Views: 363
Reputation: 6769
You are facing the problem because you are using OSX
or BSD
probably. With GNU sed
, 's/\\n/\n/g’
should have worked.
For POSIX sed
, use this,
echo "Foo\nBarFoo,\nFoo\nBarFoo" | sed 's/\\n/\
/g'
Upvotes: 3