Difference between revisions of "Pushd"
Jump to navigation
Jump to search
(Created page with "Category:Unix/Linux Usefull in scripts when you have do change directory and want to return to where you started. ;pushd <dir> :Change directory to <dir> (like cd) and add...") |
|||
Line 1: | Line 1: | ||
[[Category:Unix/Linux]] | [[Category:Unix/Linux]] | ||
Usefull in scripts when you have do change directory and want to return to where you started. | Usefull in scripts when you have do change directory and want to return to where you started. | ||
+ | |||
+ | The directory stack has the current working directory and all directory's pushed on it. | ||
;pushd <dir> | ;pushd <dir> | ||
− | : | + | :Add the current working directory to the stack and change directory to <dir>. |
+ | ;pushd | ||
+ | :Pop the last directory from the directory stack, change directory to it and push the current working directory to the stack. | ||
;popd | ;popd | ||
− | :Pop the last directory from the directory stack and change directory to | + | :Pop the last directory from the directory stack and change directory to it (return to previous directory). |
;dirs | ;dirs | ||
− | :Show the current directory stack | + | :Show the current directory and the directory stack |
Revision as of 12:45, 17 November 2021
Usefull in scripts when you have do change directory and want to return to where you started.
The directory stack has the current working directory and all directory's pushed on it.
- pushd <dir>
- Add the current working directory to the stack and change directory to <dir>.
- pushd
- Pop the last directory from the directory stack, change directory to it and push the current working directory to the stack.
- popd
- Pop the last directory from the directory stack and change directory to it (return to previous directory).
- dirs
- Show the current directory and the directory stack