Shell Scripting vs Python

Debate on whether to use shell scripts (like Bash) or general-purpose languages like Python and Ruby for automation, scripting, and complex tasks, weighing pros like ubiquity and simplicity against cons like poor scalability and maintainability.

📉 Falling 0.4x Programming Languages
5,862
Comments
20
Years Active
5
Top Authors
#5192
Topic ID

Activity Over Time

2007
3
2008
8
2009
47
2010
69
2011
105
2012
110
2013
204
2014
222
2015
266
2016
277
2017
320
2018
334
2019
382
2020
572
2021
656
2022
597
2023
605
2024
591
2025
446
2026
48

Keywords

e.g PHP JS elv.sh APL ES6 EDIT DevOps UI IMO shell bash scripts shell scripts python script shell script language scripting write

Sample Comments

sofixa Mar 27, 2022 View on HN

Shell scripts don't scale and are hard to maintain. Literally any programming language would be a better choice for the same task.

ritchiea Oct 23, 2020 View on HN

Are there ever good reasons to choose a shell script over a Python/Ruby/etc script?

Yen Jan 10, 2022 View on HN

I've also wanted a better shell scripting experience, and have bashed [no pun intended] my head against this several times. I think some of the major pain points that resist adoption of a language like Python or Ruby for in-line shell scripting or simple automation is:* These languages prefer to operate on structured data. If it parses from json, you have a much easier time. But, most commands you'd invoke from the shell emit unstructured text by default. You can deal with this, but

bluetomcat Oct 27, 2022 View on HN

Use the shell only if your script is mostly about calling other programs and filtering and redirecting their output. That's what the syntax of these languages is optimised for. As soon as you need any data manipulation (i.e. arrays, computation, etc.) it becomes a pain and Python is the much better fit.

mg Apr 24, 2022 View on HN

Pro shell scripts:- I often encounter machines without Python or Go. I never encounter machines without Bash.- Python and Go will probably change faster than Bash. So the maintenance cost of scripts in Python or Go will be higher.- When you figured out something tricky on the command line, you can paste it into a Bash script verbatim.- Bash is the perfect glue language. If the task at hand is to glue together some commands, nothing beats Bash.

brundolf Dec 7, 2024 View on HN

So it's not a fundamentally different use-case, it's just an admission that shell scripts suck at what they do?

vorador Jun 22, 2009 View on HN

Why are you against shell scripting languages ?

gtirloni Jul 27, 2024 View on HN

Python is available virtually anywhere. I'd also not use Bash unless it's a very restricted situation. Every time I'm writing a shell script that's more than a page, a sense of imminent doom starts to dominate my soul.

visarga Nov 20, 2022 View on HN

When it's more than 2-3 lines of shell script it's better to just use Python (used to be Perl).

Mawr Feb 10, 2024 View on HN

Well this doesn't make much sense.If you rightfully find bash inadequate at some point, just switch to the next most natural tool - Python. Nobody's going to be surprised when they see a Python script.If you start feeling Python is inadequate too, then:1) You're wrong, just stick to Python2) If you're so bent on doing away with familiarity, at least get as much leverage as you can in return and use a "proper" language, like Go / Rust. You get static