The popd built-in pops a directory from the directory stack.


  • popd [index]


The popd built-in removes the last entry from the directory stack, returning to the previous working directory. If index is given, the entry specified by index is removed instead of the last one.



The index of a directory stack entry you want to remove.

If omitted, +0 (the last entry) is assumed.

Exit status

The exit status of the popd built-in is zero unless there is any error.


It is an error to use this built-in when there is only one directory stack entry.

The popd built-in is a semi-special built-in. In the POSIX standard, it is defined as a command with unspecified behavior.