September 21, 2017, 10:51:50 PM

Author Topic: pushd / popd  (Read 5508 times)

0 Members and 1 Guest are viewing this topic.

Offline Metgod

  • the deranged hacker
  • Administrator
  • Forum Hero
  • *****
  • Posts: 1114
  • Country:
  • Gender: Male
pushd / popd
« on: January 29, 2003, 02:45:23 PM »
I actually first learned of this from Brian Martin's attrition, and then I realized it was also in Win2k's version of 'dos'.

If you know how the stack works, you have it made. It's all about changing directories here.

Example:

% pwd
/usr/home/metgod
% pushd /etc
% pwd
/etc
% popd
% pwd
/usr/home/metgod

Basically, if you are working in one directory, and need to do something else but making it easier to go back, you can use pushd [new dir] and then popd will take you back to the original one.

pretty useful and neat.

Met
"My Terminal is my Soul"

Offline Uneek

  • Administrator
  • Seasoned Poster
  • *****
  • Posts: 306
  • Country:
  • Gender: Male
    • HFX International Org.
Re:pushd / popd
« Reply #1 on: February 03, 2003, 03:19:30 PM »
That is a real good tip to give Metty. This tip is especially useful when going back and forth between two directories such as when working on a website and making changes to html and maybe a config file somewhere else and you have to keep going back and forth between the two.

Good job Met!
*** Sleep: A completely inadequate substitute for caffeine. ***
01010010010101000100011001001101

Offline Metgod

  • the deranged hacker
  • Administrator
  • Forum Hero
  • *****
  • Posts: 1114
  • Country:
  • Gender: Male
Re:pushd / popd
« Reply #2 on: February 04, 2003, 11:28:03 PM »
Thanks. :)

Well there are other ways to go back and forth but this has to be the easiest. There is always setting a variable and just cd'ing to it, but why when you have this ?

Bad thing is that not all shells have pushd / popd. For example, ksh does not have it. I actually like KSH but I am slowly finding that CSH does indeed have things that are very useful. :)

That reminds me though, I have another tip to post :)


Met
"My Terminal is my Soul"

Offline wilnix

  • mv user /dev/null
  • Administrator
  • Forum Hero
  • *****
  • Posts: 690
  • Country:
  • Gender: Male
  • You're not the fastest packet in the subnet...
    • Wilnix - The NetAdmin's Resource
Re:pushd / popd
« Reply #3 on: April 29, 2003, 06:58:38 PM »
another cool tip:

switch to zsh, type in a command and hit the tab...it will give you a list of commands in your path that you can use...keep hitting that tab to scroll through them...

I think that is pretty handy..

Wilnix
alt email address: wilnix@hackphreak.org