Surviving bash
The flagship product of modern unix is certainly better than any other 80s shell
August 10, 2018 — October 19, 2018
General, not macOS-specific or Linux-specific, and see also shells to yak-shave your way into whole other shell paradigms. Or fish
for a less awful user experience.
I just don’t care enough to remember. This makes me a Bad Hacker.
1 Command line tips
See command lines which are mostly bash specific because everything is hard in bash.
2 bash history
-
!n
— the nth history,!-n
the nth-most-recent!string
refers to the most recent command in the history starting with string,!?string[?]
refers to the most recent command containing string
2.1 Sensible history search
Whack this in .inputrc
3 Vars, expansions, filenames, whitespace hell
3.1 Tilde expansion
Tilde expansion is complicated. Best to avoid tildes and use ${HOME}
.
3.2 files extension munging in bash
or:
Don’t forget the quotes, or it will explode when you have spaces in your filenames and delete stuff that you loved. (I hate bash
so hard. I should probably abandon it.)
4 For loops
Watch out for horrible problems with handling of delimiters. Anyway, for loops are not insane.