Flow control in bash

Flow control in bash

It seems like whenever I want to write an if-then or case statement in bash, I spent an hour searching the web and end up finding 12 different suggested ways of doing it. I try them all and maybe one of them works if I’m lucky.

I happened to find what I think is a really great reference for this that has been a great resource for me:

Bash Scripting Tutorial – 5. If Statements

Things like string comparisons, inspecting files, boolean operations, and nested flow control are some of the topics covered. Sure, there is the official bash documentation mentions this stuff, but it’s very terse and doesn’t provide good examples, if at all.

Having said all this, I highly recommend writing command-line tools in Swift:

Creating command-line tool in Swift

Not only will you be increasing your knowledge of Swift, it’s much more powerful, more easily debuggable, and Apple makes a great IDE to help you along.