Linux-Noob Forums
Changing directorys like a stack - Printable Version

+- Linux-Noob Forums (https://www.linux-noob.com/forums)
+-- Forum: Linux Noob (https://www.linux-noob.com/forums/forum-3.html)
+--- Forum: Tips and Tricks (https://www.linux-noob.com/forums/forum-59.html)
+--- Thread: Changing directorys like a stack (/thread-2819.html)



Changing directorys like a stack - xDamox - 2005-02-24


Heres a little trick on how to change directorys like a stack with push and pop :)

 

push == add directory to the stack

pop == remote the last directory form the stack

 

The first thing we are going to do is change to a directory with push this done by

entering pushd /path/ as shwon below.

 



Code:
[damian@localhost ~]$ pushd /home/damian/public_html
~/public_html ~
[damian@localhost public_html]$ pwd
/home/damian/public_html
[damian@localhost public_html]$




 

Now you can see that the directory has changed if we wanted to go back a directory we would

pop the directory like popd as shown below.

 



Code:
[damian@localhost public_html]$ pwd
/home/damian/public_html
[damian@localhost public_html]$ popd
~
[damian@localhost ~]$ pwd
/home/damian
[damian@localhost ~]$




 

Well enjoy poping and pushing your directorys :)