What I\'m trying to do is find the current working directory and save it into a variable, so that I can run export PATH=$PATH:currentdir+somethingelse
. I\'m not
for a relative answer, use .
test with:
$ myDir=.
$ ls $myDir
$ cd /
$ ls $myDir
The first ls
will show you everything in the current directory, the second will show you everything in the root directory (/
).
You can use shell in-build variable PWD
, like this:
export PATH=$PATH:$PWD+somethingelse
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
One more variant:
export PATH=$PATH:\`pwd`:/foo/bar
Your assignment has an extra $
:
export PATH=$PATH:${PWD}:/foo/bar
current working directory variable ie full path /home/dev/other
dir=$PWD
print the full path
echo $dir