Push and Pop dirs
The dirs command, combined with pushd and popd, is very effective for tracking users' directory changes. Suppose you have to make some changes to the files present in the following directories. Instead of noting down the directories on paper, do the following:
$ pushd /home/sangeeth/soft/release2/src/ $ pushd /home/sangeeth/soft/release2/src/show/ $ pushd /home/sangeeth/soft/release2/doc/
To list all the directories, do the following:
$ dirs -l -p -d
The above command removes the topmost directory entry (/home/sangeeth/soft/release2/src/) and performs a cd to the new top directory, which in my case, will be the second directory (/home/sangeeth/soft/release2/src/show/).
Alternatively, one can pop a particular directory from the list of directories by giving the directory ID (the ID is displayed beside a directory when using dirs -l -p -d) to the popd command:
$ popd +1
More options available for using the above commands can be found by viewing the man pages.
This Tech Tip was brought to us by Sangeeth in Bangalore, India. Thanks, Sangeeth!
Instant fame is easy at Linux Journal. Just send us your useful Tech Tips to share with the Linux Community, and we'll send you a cool t-shirt for your efforts!
Please note: Tech Tips featured in this specific section of LinuxJournal.com are kindly brought to us by readers and are not necessarily tested by LinuxJournal.com editors.
Trending Topics
| You Need A Budget | Feb 10, 2012 |
| The Linux powered LAN Gaming House | Feb 08, 2012 |
| Creating a vDSO: the Colonel's Other Chicken | Feb 06, 2012 |
| Your CMS Is Not Your Web Site | Feb 01, 2012 |
| Casper, the Friendly (and Persistent) Ghost | Jan 31, 2012 |
| Razor-qt 0.4 - Qt based Desktop Environment | Jan 30, 2012 |
- Fun with ethtool
- Parallel Programming with NVIDIA CUDA
- Readers' Choice Awards 2011
- 100% disappointed with the decision to go all digital.
- Linux-Based X Terminals with XDMCP
- Validate an E-Mail Address with PHP, the Right Way
- You Need A Budget
- The Linux powered LAN Gaming House
- Why Python?
- Python for Android
- Employment Posters
5 hours 28 min ago - Sure the best distro is
6 hours 48 min ago - BeOS was the best
9 hours 32 min ago - I use Wireshark on a daily
14 hours 2 min ago - buena información
19 hours 9 min ago - One important "bucket" that I didn't note (désolé si qqun deja d
20 hours 9 min ago - Gnome3 is such a POS. No one
1 day 5 hours ago - Gnome 3 is the biggest POS
1 day 5 hours ago - I didn't knew this thing by
1 day 11 hours ago - Author's reply
1 day 15 hours ago





Comments
pushd / popd
And you probably want to create a couple of aliases in your .profile (or whichever):
alias pd=pushd
alias pop=popd
this way there are no extra keystrokes involved in typing:
pd /some/long/directory/path
versus
cd /some/long/directory/path
Push and Pop dirs
As an alternative, the "cd - " command functions like popd