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
And unfortunately,
What does it actually do? |
||||
|
avinash@avinash-Lenovo-IdeaPad-Z500:~$ cd - bash: cd: OLDPWD not set avinash@avinash-Lenovo-IdeaPad-Z500:~$ cd ~/Desktop avinash@avinash-Lenovo-IdeaPad-Z500:~/Desktop$ pwd /home/avinash/Desktop avinash@avinash-Lenovo-IdeaPad-Z500:~/Desktop$ cd - /home/avinash avinash@avinash-Lenovo-IdeaPad-Z500:~$ See also, avinash@avinash-Lenovo-IdeaPad-Z500:~$ echo $OLDPWD avinash@avinash-Lenovo-IdeaPad-Z500:~$ cd ~/Desktop avinash@avinash-Lenovo-IdeaPad-Z500:~/Desktop$ echo $OLDPWD /home/avinash avinash@avinash-Lenovo-IdeaPad-Z500:~/Desktop$ cd d avinash@avinash-Lenovo-IdeaPad-Z500:~/Desktop/d$ echo $OLDPWD /home/avinash/Desktop avinash@avinash-Lenovo-IdeaPad-Z500:~/Desktop/d$ The |
||||
|
|
|
Avinash Raj's answer is completely correct but as for the manual entry, you can get the POSIX manual pages and then
The bit that tells you all this is the OPERANDS section:
|
|||
|
|
cdis a Bash builtin. It is therefore documented inman bash-builtins, instead of its own page. This holds true for all other Bash builtins. You can tell it's a builtin because of thebash:in front of the error message. – minerz029 Mar 15 '14 at 11:26