Is there a previous-directory variable?

The environmental variable in $PWD has the current working directory. Is there a variable that contains the previous directory? If there is not, how might one be created?

I think this could be useful.


Solution 1:

Yes, there is. man bash will lead you to

   OLDPWD The previous working directory as set by the cd command.