4 ms·
Here's the short version of the Advanced Bash Scripting Guide: "Use Python". Long bash scripts are less readable and maintainable than python scripts.
by 1010011010 15y ago
Here's the short version of the Advanced Bash Scripting Guide: "Use Python".
Long bash scripts are less readable and maintainable than python scripts.
- tikhonj 15y agoIt doesn't have to be Python--you can use pretty much any language you want, so just use your favorite one be it Ruby or Python or Haskell or whatever. I personally only use Bash when the script is just a trivial translation of commands I enter.
- Maven911 15y agosometimes you have no choice, such as working on telecom systems which have a stripped down Linux version running on it and there is no python/perl interpreter available.
- tikhonj 15y agoThat's certainly a possibility. For me, however, the vast majority of scripts I write will only ever run on my own computer or maybe also on some AWS instances. I suspect this varies a lot based on what sorts of things you generally work on.
- rhizome31 15y agoSometimes you could write in Ruby/Python/Perl but it's a good idea to make a shell script instead, so that sysadmins can understand it.
- draebek 15y agoSpeaking as a person that converted a big shell script to Python a while back, I think both languages have their strengths. Writing something like: prog1 2> prog1.log | prog2 2> prog1.log | prog3 in Python is not nearly so succinct as in the shell (using only Python's standard library). And don't screw up waiting for processes or flushing buffers, things that the shell takes care of for you AFAIK. On the other hand, things like string or date manipulation are easier in Python than in the shell.
- burgerbrain 15y agoThis guide is a great read even if all you do is short bash scripts.
- wazoox 15y agoActually perl makes it way easier than python, because it supports more of bash features directly, from backticks to here-docs.
- tingletech 15y agoI needed this guide to help me write my bash script that I use to build python and all its dependencies on all the machines I need to work on. That way I'm not at the mercy of whatever out of date python happens to be installed with the package manager by the admin.
- vlisivka 15y agoShell is Lingua Franca for system administrators.