LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 10-26-2007, 09:35 PM   #1
christianunix
Member
 
Registered: Oct 2007
Posts: 40

Rep: Reputation: 15
pushd popd dirs


Could you tell me a little bit about those commands? using examples... thanks!
 
Old 10-26-2007, 10:10 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,772

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Pushd, popd, and dirs are intended for folks who spend a lot of time working from the command line.

Here's an example of how it works.

Let's say you need to go to ~/docs, a docs folder in your home directory. Instead of giving the command 'cd ~/docs', give the command 'pushd ~/docs'. That puts ~/docs at the top of the directory stack (if you run the command 'dirs' without parameters, it will show you ~/docs in the stack).

Now you need to go to ~/music for some reason, but you will need to return to ~/docs. Give the command 'pushd ~/music' to add ~/music to the stack. The dirs command will now show you: ~/music ~/docs in the stack.

To quickly get back to you docs, you give the command 'popd +1' to get to the second directory in the stack (~/docs). But, at the same time, you remove ~/docs from the stack. Dirs will only show ~/music in the stack.

If you need to go back to music again, use the pushd option to add docs back to the stack.

In this example I've used short paths. Pushd and popd don't show their worth until you are working with long paths in your commands.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
puhsd, popd implementation Rudess Linux - General 1 03-12-2007 06:37 PM
How to see just dirs with ls? d1s4st3r Linux - Newbie 3 06-04-2004 10:45 AM
ls, dirs first, files later TroelsSmit Linux - Newbie 4 05-31-2004 11:47 AM
removing dirs... chrismiceli Linux - General 5 10-25-2002 05:16 AM
hidden dirs? mighty Linux - General 3 11-03-2001 03:38 PM


All times are GMT -5. The time now is 07:12 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration