In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use "dirs", "pushd" and "popd" in Linux to operate the catalog stack, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
You can press the directory into the directory stack, or you can pop it up later. In subsequent examples, the following three commands will be used:
* dirs: displays the directory stack
* pushd: push the directory into the directory stack
* popd: pop the directory out of the directory stack
The dirs command displays the contents of the current directory and directory stack. Dirs displays the current directory even if the directory stack is empty, as shown in the following example:
one
two
three
four
five
six
# popd
-bash: popd: directory stack empty
# dirs
~
# pwd
/ home/ramesh
How to use pushd and popd? Let's create some temporary directories and push them into the directory stack.
one
two
three
four
five
six
# mkdir / tmp/dir1
# mkdir / tmp/dir2
# mkdir / tmp/dir3
# mkdir / tmp/dir4
# cd / tmp/dir1
# pushd.
one
two
three
four
five
six
seven
eight
nine
# cd / tmp/dir2
# pushd.
# cd / tmp/dir3
# pushd.
# cd / tmp/dir4
# pushd.
# dirs
/ tmp/dir4 / tmp/dir4 / tmp/dir3 / tmp/dir2 / tmp/dir1
[note: the * * directory names displayed are always the current directory, not the contents that are explicitly pressed into the stack]
At this point, the directory stack contains the following:
one
two
three
four
/ tmp/dir4
/ tmp/dir3
/ tmp/dir2
/ tmp/dir1
The pressed directory is at the top of the stack. When you execute "popd", the system jumps to the directory at the top of the stack and clears it from the stack. As shown above, * pushes / tmp/dir4 into the stack, so when you do a popd, it jumps to the / tmp/dir4 directory and removes it from the stack. As follows:
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
twenty-one
twenty-two
twenty-three
# popd
# pwd
/ tmp/dir4
[note: after executing the popd command, the directory stack includes the following directories
/ tmp/dir3
/ tmp/dir2
/ tmp/dir1]
# popd
# pwd
/ tmp/dir3
[note: after executing the popd command, the directory stack includes the following directories
/ tmp/dir2
/ tmp/dir1]
# popd
# pwd
/ tmp/dir2
[note: after executing the popd command, the directory stack includes the following directory / tmp/dir1]
# popd
# pwd
/ tmp/dir1
[note: after executing the popd command, the directory stack includes the following directories]
# popd
-bash: popd: directory stack empty
Thank you for reading this article carefully. I hope the article "how to use" dirs "," pushd "and" popd "to operate the catalog stack shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.