Effective Bash scripting for software developers
I’ve been asked many times about my shell scripts and things I’ve automated, as I’ve recently shown in a video about things I’ve automated on my system. I’ve created another video on how to effectively write Bash scripts for regular developers, who aren’t experienced on the sysadmin side of things.
First and foremost, I wouldn’t consider myself a shell scripting expert, but there are so many pragmatic and effective things that make our lives easier, that it would be a shame to not use the power of the command line and its possibility to automate things on our system.
In the video I’m sharing some Bash scripting examples and tips that will hopefully improve your scripts. You can find a full example script to copy-and-paste from on GitHub.
In the video I’m showing:
set -euo pipefail
option- Navigating to the script’s location with
cd ${0%/*}
- Using Bash traps
test
commandxargs
, piping, and loops- Number formatting with leading zeros
- Waiting and health checks
- Handling PID files
Further resources
- Example script on GitHub
- Dotfiles repository
- Things I’ve automated on my development system — Video
- Effective keyboard usage for developers — Video course
Published on System Code Geeks with permission by Sebastian Daschner, partner at our SCG program. See the original article here: Effective Bash scripting for software developers (Video) Opinions expressed by System Code Geeks contributors are their own. |