Bash doesn’t have chomp command but you can use tr to get rid of \n \r (and other) characters.
¶Posted 28 Oct 2008†AquilaX§ /dev/null ‡Comments (4)
Comments
Hei ! This simple post helpd me so much ! Thanx, i was blocked at writing a bash single-line command because I cannot eliminate spaces beetween two strings... whit
tr -t [:space:]
i resolved !
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.
A=`curl http://foo`
B=`echo $A|tr -d \\n`
Thanks.
A little late, but why not simply use bash itself for this? It is powerful enough, no need to have an external tool called:
var1="something with
space and
linefeeds"
var1=${var1//
/_}
echo $var1
(I only used _ to make it more visible here)
Comment by realtebo — 04.03.2009 @ 01:22
Comment by flipouk — 21.07.2009 @ 14:52
Comment by Ed Greenberg — 05.02.2010 @ 18:39
Comment by Ganneff — 23.04.2010 @ 16:33