Save current directory in variable using Bash?

Your assignment has an extra $:

export PATH=$PATH:${PWD}:/foo/bar

I have the following in my .bash_profile:

function mark {
    export $1=`pwd`;
}

so anytime I want to remember a directory, I can just type, e.g. mark there .

Then when I want to go back to that location, I just type cd $there


This saves the absolute path of the current working directory to the variable cwd:

cwd=$(pwd)

In your case you can just do:

export PATH=$PATH:$(pwd)+somethingelse

current working directory variable ie full path /home/dev/other

dir=$PWD

print the full path

echo $dir