Just about everything I've learned about bash has been from the #bash IRC channel on Freenode. You'll see the same repeated warnings of not learning from the public web, due to the fact that misinformation spreads like a wild fire, and some articles out there are just flat out wrong (sort of like w3schools in the #css circle).<p>There is just one thing I will <i>never</i> understand. The tired argument of "...but it isn't portable". Features that are new, and make programming bash easier (such as "[" vs "[["), are looked down upon in some circles because it isn't portable. If I'm programming for bash, then upon deployment, I'll be using bash. To use another shell, and hope it just works is a bit insane.<p>I'd also like to second using the Fish shell. Far better than bash/zsh for everyday use, and I just can't go back to other shells.
I'd be remiss if I didn't use the comments to mention the amazing and totally free, "Unix for the Beginning Mage". The author of the article also didn't mention this great resource. It's an amazing book and a short read. It took me about 3 hours to work through completely. www.unixmages.com<p>If you don't know how to use your shell, block yourself off an evening with this book and change how you forever use you computer.
> You must have spaces inside your test expressions (so [[-z $FOO]] won't work; [[ -z $FOO ]] is correct).<p>That's because '[[' is a special bash extension which started out as a better '[' which is actually a binary (/usr/bin/[). And, well, you have to have a space between an executable and its first argument.<p>(nowadays '[' and '[[' are builtins in most shells, but the external binary still exists).
I personally can't stand bash for writing scripts (it's fine for typing one-liners into terminal though). This question and its top answer capture the insanity of bash quite nicely <a href="http://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash" rel="nofollow">http://stackoverflow.com/questions/3601515/how-to-check-if-a...</a> .
How many people learned shell scripting while engaged in morally ambiguous activities? For me it was scraping for porn ~25 years ago. I imagine lots of people learned scripting while "penetration testing".
I've found that as soon as bash script goes to more than a couple lines, or as soon as it needs anything modestly complex, like "if" statements or functions, then it is almost always more efficient to write it in ipython. If you know python, then ipython is really superior way to do any ops and administration tasks. I've also found it easier to use for server setup than alternatives like ansible or puppet. I can just use standard, reusable classes and functions to do all my various activities.
What suprises me is how often Bash is being used as 'the shell' and software projects use it, even when they could simply call /bin/sh instead. This is particularly bad for people who port software to other platforms (where BSD systems dont come with Bash, for example) and have to deal with pure shell scripts calling Bash. One recent example is CoreOS/etcd that's currently dropping Bash in favor of Sh, because they simply didnt need it.<p>Bash is a shell, but Bash is not the shell!
Confession: The horrors of bash set back my programming hobby until high school. Even then, I didn't actually like interacting with my computer programmatically until I found a comfortable set of tools sometime in college. I'm lucky that my day job lets me use the tools I like and avoid systems like the bash shell.
If you're writing shell scripts, you might as well write Ansible playbooks. You can use Ansible playbooks locally without the SSH layer.<p>Bash/sh is a horrible programming language.
You don't need to learn Bash to write shell scripts. Many other languages support executing commands with special syntax (PHP and Perl have backticks for example).<p>I write my scripts in PHP if they're moderately complex, and only use Bash for dumb lists of commands.
interviewers tend not to test for shell skill even though your shell skills are usually more relevant to daily tasks. I'm debating whether to improve on my shell skills or algorithm skills.
One this which greatly helped me was understanding that [ is a program, like any other, which takes arguments. It's a small thing, but made the shall less magic.
Bash is good as a system shell. For interactive shell, zsh/fish/... wins.<p>That's why I only learn Bash. One lesson for everything for both purposes ;)
Was worth reading if only to find out about ShellCheck.<p>My current project has a lot of bash. The program itself is just `foo | bar | baz | ...`, but the associated test script has grown quite long.<p>I've just added an extra test which calls shellcheck on each script, and it's spotted a bunch of redundant code for me :)
I generally avoid aliases. I prefer to rote learn complex commands; if it's fitting for an actual shell script then I'll just bang one of those little guys out in no time.