" with "\ n" but can't find how to use <> with tr. Any idea to run this comma...">

Tr command with special character

I'm trying to replace "<br>"

with "\ n" but can't find how to use <> with tr. Any idea to run this command:

echo "HTML example<br>Print new line<br>please<br>not work" | tr "<br>" "\n" 

      

change

FatalError's answer does n't work for my OSX Lion. I don't know why, but this simple command sed

doesn't create a new line, it only returns

HTML examplenPrint new linenpleasennot work

      

I am using GNU bash version 3.2.48 (1) -release (x86_64-apple-darwin11). Any other idea?

+3


source to share


1 answer


tr

is designed to match characters to other characters. For this task, I would suggest using sed

:

echo "HTML example<br>Print new line<br>please<br>not work" | sed -e 's/<br>/\n/g'

      

This says sed

to replace each instance <br>

with a new char string.



Edit

If you have a problem since / \ in sed this will solve the problem

echo "HTML example<br>Print new line<br>please<br>not work" | sed -e "s/<br>/\\`echo -e '\n\r'`/g"

      

+5


source







All Articles