PUSHD switch to the specified path
POPD back to the last directory
======================================
PUSHD can switch to the path specified later,Accumulate stack directories by the way
Stack: This is called a stack of pushd-accumulating directories
[Email protected] etc]# pushd/etc/sysconfig/network-scripts/
/etc/sysconfig/network-scripts/etcThese two directories are cumulative stacks
Accumulate a stack directory again/test
[Email protected] network-scripts]# pushd/test/
/test/etc/sysconfig/network-scripts/etc
Dirs can view the stack directory that is currently accumulating, or you can empty the stack with dirs-c
[Email protected] test]# dirs
/test/etc/sysconfig/network-scripts/etc
Each time the pushd switches to the 2nd directory in the Stack
[Email protected] etc]# pushd
/test/etc/etc/sysconfig/network-scripts
You can pushd +1 to move the stack directory forward, by the way into the back row in the first directory
[Email protected] etc]# pushd +1
/etc/sysconfig/network-scripts/test/etc
You can add more numbers to move more directories:
[Email protected] network-scripts]# pushd +2
/etc/etc/sysconfig/network-scripts/test
======================================
POPD back to the last directory you went to.
======================================
In the actual application of the popd and pushd commands, it comes in handy when writing shell scripts-you don't have to remember where you came from, and as long as you execute popd, you can go back to your directory.
This article from "crazywing" blog, reproduced please contact the author!
Linux Alternative switching path mode pushd and POPD