Save current directory in variable using Bash? Save current directory in variable using Bash? bash bash

Save current directory in variable using Bash?


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


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


Your assignment has an extra $:

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