Tag command-line

 Bookmark

I used to write a lot of shell scripts before realising that what I was trying to do was treat shell scripting as a "full" scripting language (I won't define here what I mean by "full").

Its not - reach for a higher level scripting language like Ruby or Python when things are getting more complicated, and allow shell scripts to glue things together, or be for quick tasks maybe a few lines long.

When you do write them, this advice is great but it's definitely worth gaining understanding of when you should and shouldn't use them.

 Bookmark

This is a great post - I thoroughly recommend learning how to use common commandline tools such as awk, grep, sed, but also adopting a scripting language for more complicated stuff. I don't mean Bash, or another shell scripting language, but something like Node, Python or Ruby, as it'll give you the opportunity for a greater standard library, as well as tonnes of packages built by others.

 Bookmark

In every programming language, there is a linting tool that can help pick up on some common style issues. ShellCheck isn't one of those - it's so much more!

I've been using it for many years now, and since it came into my life it's honestly changed the way I use shell scripts. There have been so many pitfalls that I've avoided falling into since learning about them (and adding ShellCheck to my Vim linting setup.

This is a great read from Vidar, the ShellCheck author, about a case where it could've caught issues that caused the deletion of a production database!