Problem in Concatination of string in bash scripts containing back slashes.

My script is as follows:

#!/bin/bash
STR1="test"
echo $STR1
STR2="/bldtmp/"$STR1
echo $STR2
STR3=$STR2'/tmp'
echo $STR3

output i am geting
----------------

test
/bldtmp/test
/tmptmp/test

but my need is:
------------------

test
/bldtmp/test
/bldtmp/test/tmp

please help me in this?

Your script file is in DOS format. Try converting it to Unix format like this:

tr -d '\r' < script > newscript
1 Like