I typed cd -
in terminal by mistake today, and I got an error saying:
bash: cd: OLDPWD not set
And unfortunately, man cd
doesn't exist.
No manual entry for cd
What does it actually do?
I typed cd -
in terminal by mistake today, and I got an error saying:
bash: cd: OLDPWD not set
And unfortunately, man cd
doesn't exist.
No manual entry for cd
What does it actually do?
cd -
switches between the old and new present working directories.See also,
The
$OLDPWD
variable stores the path of the previous present working directory.Avinash Raj's answer is completely correct but as for the manual entry, you can get the POSIX manual pages and then
man cd
will work:The bit that tells you all this is the OPERANDS section: