- Published on
popd command-delete records from the shell directory stack
Jonas
1 min read
Used to delete records from the Shell directory stack. If no option is added, the popd command deletes the record at the top of the Shell directory stack first, and then switches the current directory to the top directory of the new Shell directory stack.
Syntax: popd [parameter]
Command parameters
-n | Delete the nth directory from the right (n starts counting from 0) |
+n | Delete the nth directory from the left (n starts counting from 0) |
Example
Display the contents of the Shell directory stack, one per line:
[root@linuxstar ~]# dirs -v 0 /sbin 1 /etc 2 /var/log
Remove /sbin from the shell directory stack:
[root@linuxstar ~]# popd /etc /var/log
Display the current working directory:
[root@linuxstar ~]# pwd etc
Delete the top directory from the directory stack:
[root@linuxstar ~]# popd /var/log
Delete the second directory from the right from the directory stack:
[root@linuxstar ~]# popd -2