Member-only story

Porting Bash Scripts to Python

This ain’t a tutorial on how to use LLMs for porting code, I just provide my thoughts and reasons on why I’m preferring Python over Bash for writing automation scripts as well as providing three helpful tips to get started writing Python scripts to replace Bash

Basil A.
3 min readJul 24, 2024
Photo by Johann Walter Bantz on Unsplash

Why Move to Python?

I’ve recently decided to stop writing bash scripts for daily devop tasks and instead use Python. The reasons for this might be obvious to many, but just to quickly summarize, here are my reasons:

  1. Python code is more clearly understood than Bash code. Bash code is cryptic, whether you are writing a for loop, checking a file exists, everything looks cryptic.
  2. Python code is more powerful than bash. It allows you to easily create a thread pool to parallelize tasks, run complex arithmetic operations and apply imperative or functional styles to your code.
  3. Python code is more versatile considering the number of libraries its support and the ease of using those libraries.

Three Useful Tips when migrating Bash Code to Python

--

--

Basil A.
Basil A.

Written by Basil A.

A Software Engineer with interests in System Design and Software Engineering done right.

No responses yet