Bash Shell Scripting

Updated 20-Sep-2023

Bash being the most common shell, it makes sense to learn bash shell scripting. I didn't think this at first and later came to the conclusion, having spent time with Fish Shell. However, Bash is definitely old and creaky with some frankly ridiculous implementation details. Fish can be installed most everywhere, and is generally superior in many ways. Where it is not, commands can simply be run in Bash.

Variables, Conditionals, Utilities

Most of Bash scripting is variables (including initially environment variables), conditionals, and utilities. For example, the common task of changing the names of files in a directory, copying them, moving them, etc., is a combination of setting up variables (e.g., $f for filenames of a given sort), then looping over (while) them and executing various commands (mv, cp, etc.).

See Also

> Note to self -- collapse these two path articles into a single one

Touring Complete Programming Language

Apparently, Bash is Turing complete, which means it is fairly sophisticated, complex, and thorough. That doesn't mean it should be used for everything, but certainly can be used for many things. Python would be a competitor in terms of doing shell scripting, but it would depend on how complicated, or exactly what kind of functionality is needed in order to prefer Python over Bash in terms of scripting.

Current Assessment of Shell Scripting in Bash

For scripts that run simple commands (such as openvpn or autossh then Bash simply handles errors better with an old-school shim when missing a shebang. However, dealing with ease and elegance with actual scripting, and working from a modern design document, Fish is hard to beat.