Réponses:
cd - bascule entre l'ancien et le nouveau répertoire de travail actuel.
avinash @ avinash-Lenovo-IdeaPad-Z500: ~ $ cd - bash: cd: OLDPWD non défini avinash @ avinash-Lenovo-IdeaPad-Z500: ~ $ cd ~ / Bureau avinash @ avinash-Lenovo-IdeaPad-Z500: ~ / Desktop $ pwd / home / avinash / Bureau avinash @ avinash-Lenovo-IdeaPad-Z500: ~ / Bureau $ cd - / accueil / avinash avinash @ avinash-Lenovo-IdeaPad-Z500: ~ $
Voir également,
avinash @ avinash-Lenovo-IdeaPad-Z500: ~ $ echo $ OLDPWD avinash @ avinash-Lenovo-IdeaPad-Z500: ~ $ cd ~ / Bureau avinash @ avinash-Lenovo-IdeaPad-Z500: ~ / Desktop $ echo $ OLDPWD / accueil / avinash avinash @ avinash-Lenovo-IdeaPad-Z500: ~ / Bureau $ cd d avinash @ avinash-Lenovo-IdeaPad-Z500: ~ / Bureau / d $ echo $ OLDPWD / home / avinash / Bureau avinash @ avinash-Lenovo-IdeaPad-Z500: ~ / Bureau / d $
La $OLDPWDvariable stocke le chemin du précédent répertoire de travail actuel.
La réponse d'Avinash Raj est complètement correcte, mais en ce qui concerne la saisie manuelle, vous pouvez obtenir les pages de manuel POSIX et ensuite man cdfonctionner:
sudo apt-get install manpages-posix
man cd
Le bit qui vous dit tout cela est la section OPERANDS:
- When a hyphen is used as the operand, this shall be equivalent to the command:
cd "$OLDPWD" && pwd
which changes to the previous working directory and then writes its name.
cdest un Bash intégré. Il est donc documenté dansman bash-builtins, au lieu de sa propre page. Cela vaut pour tous les autres builds Bash. Vous pouvez dire que c'est une fonction intégrée en raison dubash:devant du message d'erreur.