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
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:
- 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.
- 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.
- Python code is more versatile considering the number of libraries its support and the ease of using those libraries.