A few useful Bash features that may not be well known
Hosted by Dave Morriss on Wednesday 2015-08-26 is flagged as Explicit and is released under a CC-BY-SA license.
Listen in ogg,
mp3 format. | Comments (2)
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:
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.
I have written out a moderately long set of notes about these commands and these are available here https://hackerpublicradio.org/eps/hpr1843_full_shownotes.html.
Automatically generated using whisper
whisper --model tiny --language en hpr1843.wav
Comment #1 posted on 2015-08-27T06:40:23Z by Ken Fallon
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
That jumps you back to the previous directory. Running it again brings you back to where you started.
Comment #2 posted on 2015-08-28T11:49:33Z 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:
pushd -n ~/Community_News/; pushd -n ~/Database/; pushd -n ~/IA/; pushd -n ~/content_cleaning/
(note the '~/' at the start to make these absolute paths)
Then I might hop around between directories with for example:
Even this has been largely superseded by screen and tmux, I will admit.
I'm probably just old-fashioned :-)
<< First, < Previous, Next >, Latest >>
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 :).