Hi people,
I have a little problem with a bash script of mine.
DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PATH="/System/java/"
echo $DIR #gives the working directory /media/*name of usb stick*
echo $PATH #gives /System/java/
echo $DIR$PATH #gives /System/java/, should give /media/*name of usb stick*/System/java/
FULL=$DIR$PATH #should concatenate
echo $FULL #gives /System/java/, should give /media/*name of usb stick*/System/java/
FULL=${DIR}/System/java/ #should concatenate
echo $FULL #gives /System/java/, should give /media/*name of usb stick*/System/java/
The script is stored on a USB stick
My goal is to get the current directory (where the script lives, not the working directory), which is stored in DIR. (This works)
Then I want to append the string "/System/java/" to it. Then I can use that string to do my stuff (not important for this question..)
I just can't figure out why it gives me this output...
Bash version 4.1.10, if anyone cares, since this stuff should work since version 3.1....
Can somebody help me with this?
EDIT: If I do this:
echo ____________________$DIR$PATH
I get this: /System/java/___________/media/*name of usb stick*
It's like it first prints the underscores, then the DIR and then puts PATH over all that..