Helped me too. I had a curl that returned a single line, but curl adds a linefeed that I didn't need. It's easy to deal with in perl, but I'm working in shell today.
B=`echo $A|tr -d \\n`
A little late, but why not simply use bash itself for this? It is powerful enough, no need to have an external tool called:
(I only used _ to make it more visible here)