Bash is everywhere and I write a stupid amount of it for that very reason. It’s pretty hard to write good Bash. Here are some resources I’ve used to try and level up my code.
I think the pure Bash bible was a side project that resulted from Neofetch.
The reason I like to refer to these projects is that Dylan has pretty much covered everything you’d ever want to do in Bash and Linux.
Neofetch is a CLI tool that reports back information about *nix systems; like your CPU count/speed, RAM amount, disk usage, etc. It works on just about every Linux there is as far as I can tell. So if you ever find yourself looking to query free RAM on macOS and Linux, neofetch already figured it out for you. Funny enough, I don’t actually use it on any of my computers. But, I’ve referred to it many times over the years to see how to find information on a server.
The pure-bash-bible is helpful for Bash syntax and generally doing things that would normally require you to use an external program. I’ve found this doesn’t really matter a ton in practice, since most POSIX systems end up with the same utilities. It can be handy if you’re targeting macOS/BSD and Linux/GNU where some utilities work differently.
Finally, I can’t mention Bash resources and not preach about ShellCheck.
This tool helps you find bugs and follow best practices in your shell scripts.
Things like quoting variables or using
= when you meant
-eq get called
out. There are a variety of plugins available for various
(like vim-shellcheck by some dude named Josh).
I use ShellCheck for every Bash script I write now, and I force it on every person I see writing Bash code. Seriously, do yourself a favor and use it.