When using the terminal, sometimes you will need to switch to and fro between two directories. When the path to a directory is too long, to save time, you can use the two command "pushd" and "popd" for a quick switching between these two directories without the need to re-typing the directory path.
The "pushd" command function is to save the current working directory in memory so it can be returned to at any time. "pushd" is also used to change to a new directory so you can use it instead of the "cd" command. The "popd" command returns to the path at the top of the directory stack.
The way you use "pushd" and "popd" is very simple. When you are in a certain directory and want to switch to another directory, instead of "cd", you can use "pushd":
pushd /path/to/new/directory
With this command, you will move to the new directory and the original directory is saved in the memory. After finishing work in the new directory, to return to the original directory, just type
popd
And you will move to the first directory.
No comments:
Post a Comment