I have a file that contains strings with newlines, like this:
{"name": "John\n\nMeyer"}
{"name": "Mary\n\nSmith"}
How can I remove them using the tr
tool?
I'm trying this, but the output is bad:
$ cat f.json | tr -s '\\n\\n' ' '
{" ame": "Joh Meyer"}
{" ame": "Mary Smith"}
With Perl, that same regex works fine:
$ cat f.json | perl -pe 's/\\n\\n/ /g'
{"name": "John Meyer"}
{"name": "Mary Smith"}
tr
substitutes single characters, not strings. – Bombazine\\n
are newlines and not two characters slash \ andn
? – Bombazine