Is there an advantage to using Bash over Perl or Python? [closed] Is there an advantage to using Bash over Perl or Python? [closed] bash bash

Is there an advantage to using Bash over Perl or Python? [closed]


Two advantages come to mind:

  • Simplicity: direct access to all wonderful linux tools wc, ls, cat, grep, sed... etc.Why constantly use python's subprocess module?

  • I'm increasingly fond of using gnu parallel, with which you can execute your bash scripts in parallel. E.g. from the man page, batch create thumbs of all jpgs in directory in parallel:

    ls *.jpg | parallel convert -geometry 120 {} thumb_{}

By the way, I usually have some python calls in my bash scripts (e.g. for plotting). Use whatever is best for the task!


Perl scripts are usually (if not 100% of the times) faster than bash.

A discussion on that: Perl vs Bash


bash isn't a language so much as a command interpreter that's been hacked to death to allow for things that make it look like a scripting language. It's great for the simplest 1-5 line one-off tasks, but things that are dead simple in Perl or Python like array manipulation are horribly ugly in bash. I also find that bash tends not to pass two critical rules of thumb:

  1. The 6-month rule, which says you should be able to easily discern the purpose and basic mechanics of a script you wrote but haven't looked at in 6 months.

  2. The 'WTF per minute' rule. Everyone has their limit, and mine is pretty small. Once I get to 3 WTFs/min, I'm looking elsewhere.

As for 'shelling out' in scripting languages like Perl and Python, I find that I almost never need to do this, fwiw (disclaimer: I code almost 100% in Python). The Python os and shutil modules have most of what I need most of the time, and there are built-in modules for handling tarfiles, gzip files, zip files, etc. There's a glob module, an fnmatch module... there's a lot of stuff there. If you come across something you need to parallelize, then indent your code a level, put it in a 'run()' method, put that in a class that extends either threading.Thread or multiprocessing.Process, instantiate as many of those as you want, calling 'start()' on each one. Less than 5 minutes to get parallel execution generally.

Best of luck. Hope this helps.