|
|
|
|
|
by ideasman42
1493 days ago
|
|
I switched to ZSH and was quite happy with it, now using FISH - mainly because of it's excellent auto-completion that displays as you type. Otherwise both ZSH and FISH are good options IMHO. Although for typical "shell-scripting" I still use BASH for the most-part where scripting languages like Python aren't as suitable, so my scripts can be used on other peoples systems. |
|
I am admittedly a not very good bash'er, and this week at work I whipped up my first "complicated" bash script, but ended up rewriting it in Python. It might have just been the case that the IO bound nature of my task fell right into Python's strong suits (async IO), but it had me wondering what scenarios a bash script would be better.
Essentially I had to:
* iterate over a list of hundreds of thousands of files
* make an api call via aws cli
* take result and process it through a few shell utilities (`date` and `touch`) to then update the timestamps on the files.
I initially wrote it in bash which spawned ~16 background workers (threads/processes?) via `&` and blocking via `wait -n`. This "worked" but was pretty slow as the threads were thrashing checking for responses. Doing anything more than 16 caused my computer to crawl lol.
I then rewrote it in Python with async IO and the async subprocess API (to run shell commands) and it was an order of magnitude faster.
I wish I was better at bash, but maybe I just haven't spent enough time with it. Doing this task made me feel like I could pretty much doing most things in Python if I need a non-trivial script.