What kind of Bash scripts have you written?

Inspired by this post by @stefan.jarina, I’m curious about the kind of Bash scripts you’ve written and whether you still use Bash given there are a lot of scripting languages around now…

Corresponding tweet for this thread:

Share link for this tweet.

I can’t shut up about the last task I did for one of my former customers: I made a script that scraped our own app’s invoice pages and printed all the scraped pages to PDF. It also utilized parallel so several downloads and PDF creations were happening at the same time.

The whole script, with good comments included, is no more than 45 or so lines yet it was one of the most productive scripts I have ever written. Our business people – who wanted the PDF invoices – were thrilled.


Just a bit of a context to why even have a need to write a bash script.

I mostly write automation, for windows in powershell, for linux in python. and mostly leveraging ansible.

However the need was to have a script that can be deployed to server using azure custom scripts extensions. My first idea was to simply have a thin wrapper above my python scripts, that wil install what is needed and then launch python goodness. however this proved to be a bit frustrating, because different systems have different package names, dependencies and etc.

as soon as you have to support ubuntu 18.04/20.04, red-hat/centos 7 and 8, openSUSE, oracle linux and some more…

on one system there is only python3, on other only python2, on some python3.5 on other python3.8, on some package is called libselinux-python, on other python3-selinux and so on :smiley:

I just said screw it, will write this in bash and be done with it, I can be sure, that will work reliably on every system.

my wish for 2021 is to get rid of python2 and be done with this nonsense and have everywhere only python3 so we can finally count on it in our automation :slight_smile:

PS: sorry for a small rant


No problem Stefan! We even have a rant icon for threads tagged with #rant :laughing:

Back on topic…

I think the largest Bash program I have written is a deployment script. I just found that I didn’t need many of the features of tools like Capistrano (such as rollbacks) so ended up writing my own. I like having the control it offers, such as being able to put the site in maintenance mode when pushing an update.

As we have new giveaways every year it is also used for that, and it has flags that can be used for the initial set-up up sites (eg, migrate db, populate db, etc).

Bash is a neat little language :smiley:


Nice, sounds pretty cool!


I love BASH, with moderate knowledge of it you can do so much with ease.
I especially like using its arrays and rematch regex for quick utilities where reaching for Python or PERL otherwise just doesn’t seem worth the time or potential loss of portability.

Most recently I wrote a a script to scrape a visualisation graph from an external webpage, refreshing its view every 10minutes but only between core business hours, and sleeping precisely until the next day when outside those hours, displaying it directly in the terminal with iTerms imgcat :slight_smile:

But my most valuable and oft used script is one I wrote to update my DDNS IP address in Cloudflare.