This is an open series in which Hacker Public Radio Listeners can share their Bash scripting knowledge and experience with the community. General programming topics and Bash commands are explored along with some tutorials for the complete novice.
Today I want to talk about three Bash commands:
pushd
popd
dirs
These let you change directory on a Linux system (and others which support Bash) but keep a record of where you have been in a stack structure. The stack can be viewed and manipulated with these commands as well.
Comment #1 posted on 2015-08-27 06:40:23 by Ken Fallon
Obsolete ?
Hi Dave,
I could never get my head around these commands, and your show has clarified them for me.
I have never been able to get a use case for this, that cannot be done using
cd -
That jumps you back to the previous directory. Running it again brings you back to where you started.
Ken.
Comment #2 posted on 2015-08-28 11:49:33 by Dave Morriss
Maybe obsolescent or outmoded
As I said in the episode, I use these less than I used to, though I do still use them.
cd , cd- and cd only let you move between a given directory, the previous one and $HOME, whereas pushd and popd let you manipulate a much larger collection of directories.
If I'm connecting to a remote VPS or something I might do this:
(note the '~/' at the start to make these absolute paths)
Then I might hop around between directories with for example:
pushd +4
Even this has been largely superseded by screen and tmux, I will admit.
I'm probably just old-fashioned :-)
Leave Comment
Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.
Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).