BASH

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 command
  • xargs, piping, and loops
  • Number formatting with leading zeros
  • Waiting and health checks
  • Handling PID files

Further resources

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.

Sebastian Daschner

Sebastian Daschner is a self-employed Java consultant and trainer. He is the author of the book 'Architecting Modern Java EE Applications'. Sebastian is a Java Champion, Oracle Developer Champion and JavaOne Rockstar.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button