1.CD-The function is to quickly switch to the previous directory , as follows:
Copy Code code as follows:
amosli@amosli-pc:~$ CD learn/fd/
amosli@amosli-pc:~/learn/fd$ CD-
/home/amosli
2.dirs: Display the directory stack, listing the list of directories saved in the current stack
Copy Code code as follows:
amosli@amosli-pc:~/learn/fd$ dirs
~/learn/fd
Note: the-p parameter of dirs can display the list of directories in the stack in one directory per row
-v argument can be numbered before the table of contents
Note: When-V is not added-P can also be displayed as a table of contents per row
Copy Code code as follows:
amosli@amosli-pc:~/learn/fd$ Dirs-p-V
0 ~/LEARN/FD
The directory into the stack is on top
Introduction to the 3.PUSHD,POPD command
PUSHD: Switches to a directory as a parameter and presses the original directory and current directory into a virtual stack
If you do not specify a parameter, the previous directory is returned and the last two directories in the stack are exchanged
POPD: Removes the most recent directory from the stack
Copy Code code as follows:
amosli@amosli-pc:/$ pushd bin/
/bin/
amosli@amosli-pc:/bin$ pushd/home/amosli/learn/fd/
~/learn/fd/bin/
amosli@amosli-pc:~/learn/fd$ Dirs-p-V
~/learn/fd
/bin
/
amosli@amosli-pc:~/learn/fd$ pushd/home/amosli/develop/
~/develop ~/learn/fd/bin/
amosli@amosli-pc:~/develop$ Dirs-p-V
~/develop
~/learn/fd
/bin
/
The above uses the PUSHD command to push/, bin/,/home/amosli/learn/fd/,/HOME/AMOSLI/DEVELOP/4 directories into the stack, which is the data structure of the LIFO (Lifo,last in first).
So how do I switch directories?
1 if it is directly pushd without parameters, then switch directly to the nearest directory.
Copy Code code as follows:
amosli@amosli-pc:~/develop$ pushd
~/LEARN/FD ~/develop/bin/
amosli@amosli-pc:~/learn/fd$
2) pushd +n
You can also follow the numbers to switch directly to the appropriate directory. For example, switch to/(root directory) as follows:
Copy Code code as follows:
[Code]
amosli@amosli-pc:~/learn/fd$ pushd +3
/~/LEARN/FD ~/develop/bin
amosli@amosli-pc:/$ ls
How do I remove a directory?
1) popd directly remove the nearest directory
Copy Code code as follows:
amosli@amosli-pc:/$ Dirs-p-V
0/
1 ~/learn/fd
2 ~/develop
3/bin
amosli@amosli-pc:/$ popd
~/LEARN/FD ~/develop/bin
amosli@amosli-pc:~/learn/fd$ Dirs-p-V
0 ~/LEARN/FD
1 ~/develop
2/bin
2) popd +n
Just follow the numbers, remove the specified directory
Copy Code code as follows:
amosli@amosli-pc:~/learn/fd$ popd +1
~/learn/fd/bin
amosli@amosli-pc:~/learn/fd$ Dirs-p-V
0 ~/LEARN/FD
1/bin