Ask Your Question
2

Problems with concatination of parameters

asked 2015-10-06 03:30:24 -0500

Ursus gravatar image

I have a shell script assigning a parameter a value.

DL_HOME="/dataland"

Running this script, and at the promt doing: echo $DL_HOME gives the answer /dataland

If I then at the promp ar assigning a new parameter

BI_PATH=$DL_HOME"/bin"

and writes echo $BI_PATH gives the answer /binaland which is not what I want

If I instead writes all of the assigments at the promt

DL_HOME="/dataland" BI_PATH=$DL_HOME"/bin" echo $BI_PATH

it gives the right answer /dataland/bin

What am I doing wrong?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-10-07 15:26:39 -0500

sergiomb gravatar image
BI_PATH=$DL_HOME"/bin"

change to

BI_PATH="$DL_HOME/bin"
edit flag offensive delete link more

Comments

You can also use braces to make it more readable and prevent variable collisions, for example:

BAD="stinky"
BADDER="rotten"
THING="garbage"
echo "$BAD $BADDER ${BAD}DER $THING"
randomuser gravatar imagerandomuser ( 2015-10-08 23:43:07 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-10-06 03:30:24 -0500

Seen: 32 times

Last updated: Oct 07 '15