Hey I've been using Linux for a while and thought it was time to finally dive into shell scripting.
The problem is I've failed to find any significant advantage of using Bash over something like Perl or Python. Are there any performance or power differences between the two? I'd figure Python/Perl would be more well suited as far as power and efficiency goes.
Performance-wise bash outperforms python in the process startup time. This shows a huge difference however bash execution time degrades quickly if it has to do anything sensible since it usually must call external processes. If you care about performance use bash only for: really simple and frequently called scripts.
So yeah, Perl will generally be a lot faster if you're doing anything that you wouldn't normally do in bash anyways.
Bash is a Unix shell and command language which is commonly used for system administration tasks whereas Python/Perl/Ruby is used for general-purpose programming. But all of these can handle all kind of problems and all have different strengths over the rest.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With