pushd and popd
Both
pushd and popd are shell builtin commands. The pushd command is used to save the current directory into a stack and move to a new directory. Furthermore, popd can be used to return back to the previous directory that is on top of the stack.
It is very useful when we have to switch between two directories frequently.
The syntax of using pushd is as follows:
pushd [directory]
If no directory is specified, pushd changes the directory to whatever is on the top of the stack.
The syntax of using popd is as follows:
popd
Using the popd switch, we can go back to the previous directory that is on top of the stack and pop that directory from stack.
The following example counts the number of files or directories in a specified directory ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access