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.

1 Answer

Yes, there is. man bash will lead you to

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest