RSS | technovelty home | page of ian | ianw@ieee.org
After looking at some shell scripts today it seems the very handy
pushd and popd aren't used enough in the
wild.
If you're just popping into a new directory for a moment to do
something, then want to return to the directory you came from, use
pushd newdir; it will push the current directory to the
top of the directory stack (actually the DIRSTACK
environment variable) and cd you there.
When you're done, use popd to go back to where you
came from. Obviously you can keep pushing onto the stack and nest
your directory changes deeper. Never again shall you need to manually
remember $PWD!
ianw@lime:~$ pushd /tmp /tmp ~ ianw@lime:/tmp$ echo do something in /tmp do something in /tmp ianw@lime:/tmp$ popd ~ ianw@lime:~$
posted at: Wed, 07 Sep 2005 15:37 | in /linux/tips | permalink | add comment (0 others)

This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.