sebastiandaschner blog


Effective Bash scripting for software developers (Video)

#automation #productivity #linux #commandline thursday, may 27, 2021

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 command

  • xargs, piping, and loops

  • Number formatting with leading zeros

  • Waiting and health checks

  • Handling PID files

 

Further resources

 

Found the post useful? Then you might enjoy my Developer Productivity Masterclass.