Bash Tips #6 – Embedding Files in a Single Bash Script

Scripts that utilize multiple files are not easy to distribute. We usually distribute those as archives and rely on the end user to unpack and run them from a predetermined location. To improve the experience we can instead prepare a single script with other files embedded inside it. Here are the goals: The first requirement … Continue reading "Bash Tips #6 – Embedding Files in a Single Bash Script"

Read More

Bash Tips #5 – Parallelism using xargs

Running things in parallel in bash scripts may seem like a difficult task, but thanks to great utility programs that are available out-of-the-box on most GNU/Linux distributions it is not. In this brief article, I would like to focus on using xargs to run operations in parallel in a convenient manner. This is an approach … Continue reading "Bash Tips #5 – Parallelism using xargs"

Read More

Bash Tips #4 – Error Handling in Bash Scripts

There is no single way to handle unexpected behavior in our bash scripts. By default, bash simply ignores any failed calls and proceeds with the execution. Therefore we have to explicitly implement behavior that would help us handle such events. I would like to present a few simple techniques that can be used in these … Continue reading "Bash Tips #4 – Error Handling in Bash Scripts"

Read More

Bash Tips #3 – Templating in Bash Scripts

Software deployment systems such as Ansible or Puppet come with a templating engine to help us create and manage configuration files. Such functionality can be also achieved using bash. It might not be as easy to use or feature-rich, but it is a mechanism that can be useful when you cannot or choose not to … Continue reading "Bash Tips #3 – Templating in Bash Scripts"

Read More

Bash Tips #2 – Splitting Shell Scripts to Improve Readability

Codebase grows over time and so do shell scripts. Those usually start small and serve a single purpose, but new features get added, unforeseen situations are handled, and suddenly shell scripts have hundreds of lines, losing readability in the process. From what I have observed when collaborating with other developers, it is in our nature to … Continue reading "Bash Tips #2 – Splitting Shell Scripts to Improve Readability"

Read More

Bash Tips #1 – Logging in Shell Scripts

A visual indication of steps performed by a shell script not only improves the experience of the user of the script, but a well detailed log helps to debug any problems that could occur and to confirm that the script performed the operations correctly. Introducing a proper logging to shell scripts can help with that. … Continue reading "Bash Tips #1 – Logging in Shell Scripts"

Read More