Learning_the_bash_Shell_Third_Edition 9/n
Advanced Examples: pushd and popd
Task 4-8
The functions pushd and popd implement a stack of directories that enable you to move |
pushd ( )
{
dirname=$1
DIR_STACK="$dirname ${DIR_STACK:-$PWD' '}"
cd ${dirname:?"missing directory name."}
echo "$DIR_STACK"
}
popd ( )
{
DIR_STACK=${DIR_STACK#* }
cd ${DIR_STACK%% *}
echo "$PWD"
}
浙公网安备 33010602011771号