Frequently Asked Question

When should I write bash versus when should I switch to Python?

Bash wins for short orchestration: anything that is mostly running other commands, piping output around, manipulating files by name, and gluing existing tools together. The shell's job is precisely this kind of work, and it does it more concisely than any programming language. A ten-line bash script that tars up a directory, uploads it to S3, and updates a manifest is shorter, clearer, and easier to read than the equivalent Python. If your script is a sequence of commands with a sprinkle of if and for, stay in bash.

Switch to Python (or Go, or whatever your team uses) when you start needing real programming primitives: structured data (lists of dicts, JSON, CSV), arithmetic beyond integers, complex string manipulation, network protocols, libraries, unit tests, error types richer than exit codes. The pragmatic threshold is around a hundred lines or the moment you reach for an array of arrays, anything more sophisticated than that becomes painful in bash quickly. Other early warning signs: you find yourself parsing JSON with jq pipelines, doing floating-point arithmetic with bc, or writing your own option parser. Each one is a hint that you have outgrown the shell.

Further reading and video