A simple cd - will move you back to your previous directory and print the directory's name out.
The - alone is expanded to your previous directory. This is explained in the cd section of man bash:
An argument of - is converted to $OLDPWD before the directory change is attempted. If a non-empty directory name from CDPATH is used, or if - is the first argument, and the directory change is successful, the absolute pathname of the new working directory is written to the standard output. The return value is true if the directory was successfully changed; false otherwise.
Comments
Post a Comment