0
votes

I have a file with several thousand lines. I'm looking to replace newline character with ' || ' (that is ||)

I'm wanting to this via bash on Ubuntu 20.04

I've tried the following but in vain -

tr '\n' ' || ' < input.txt
tr '\n' ' \|| ' < input.txt
tr '\n' ' \|\| ' < input.txt

I'm not able to work out what I'm doing wrong. Please can someone help me spot my mistake?

1
Please add sample input (no descriptions, no images, no links) and your desired output for that sample input to your question (no comment).Cyrus

1 Answers

0
votes

Actually, just after posting this question, I worked this out. Leaving the answer here if someone someday finds it helpful

perl -p -e 's/\n/ || / ' input.txt