Linuxstar
Published on

pushed command-add records to the shell directory stack

Jonas

Jonas

1 min read

The pushed command is used to add a directory to the stack, add a record to the top of the directory stack, and switch to the directory. If no parameters are added, the two directories at the top of the record stack will swap positions.

Syntax: pushed [parameter] [directory]

Command parameters
-n Move the nth directory from the right to the top of the stack (n starts counting from 0)
+n Move the nth directory from the left to the top of the stack (n starts counting from 0)
Example

Display Shell's default directory stack:

[root@linuxstar ~]# dirs
/var/log

Add the directory /etc to the Shell directory stack:

[root@linuxstar ~]# pushed /etc

Display the contents of the Shell directory stack, one record per line, plus the serial number:

[root@linuxstar ~]# dirs -v
0 /sbin
1 /etc
2 /var/log

Move the first record to the top of the stack:

[root@linuxstar ~]# pushed -1
/etc /var/log /sbin