Restore the previous value of the current directory.
Syntax popd [+N | -N] [-n] Key +N Remove the Nth directory (counting from the left of the list printed by dirs), starting with zero. -N Remove the Nth directory (counting from the right of the list printed by dirs), starting with zero. -n Suppress the normal change of directory when removing directories from the stack, so that only the stack is manipulated.
Without arguments, pops the directory stack and returns to the new top directory. The elements are numbered from 0 starting at the first directory listed with dirs; i.e., popd is equivalent to popd +0.
all forms of popd print the final directory stack
This is a BASH shell builtin, to display your local syntax from the bash prompt type: help popd
"Half a pound of tuppenny rice, Half a pound of treacle, that's the way the money goes, Pop! goes the weasel"
Related macOS commands:
pushd - Save and then change the current directory
dirs - Display list of remembered directories