3 ms·
When I see stuff like this I always wonder how people above about finding these capabilities. I don't use bash every day so I tend to forget a lot of "tricks".
by Ididntdothis 7y ago
When I see stuff like this I always wonder how people above about finding these capabilities. I don't use bash every day so I tend to forget a lot of "tricks". But then I get annoyed when I see people write about really neat stuff that can be done in bash but couldn't figure out myself.
- chubot 7y ago(author here) I agree a lot of this stuff hasn't been documented well in existing shell resources. I should write more about it, but I'm still busy working on the Oil shell implementation nearly 3 years later :) I should have written a post about xargs 2 years ago, which has nontrivial compositional patterns. Hopefully next year! I still recommend The Art of Unix Programming (mentioned in this post), which is more generally about Unix design, not about shell in particular. I also got a lot of ideas by reading DJB's shell and C code, and his papers (e.g. Ten Years of qmail Security). I probably learned about DJB 10 years ago from Hacker News. I would say there's a lot of "tribal knowledge" in people's heads, and online forums are where it gets disseminated. For me those forums were Usenet, the old JOS forum, and Hacker News and lobste.rs these days. ---- Neil Stephenson has a good quote about this "oral history" Unix, by contrast, is not so much a product as it is a painstakingly compiled oral history of the hacker subculture. It is our Gilgamesh epic. https://en.wikipedia.org/wiki/In_the_Beginning..._Was_the_Command_Line https://en.wikipedia.org/wiki/In_the_Beginning..._Was_the_Co... https://en.wikipedia.org/wiki/Epic_of_Gilgamesh https://en.wikipedia.org/wiki/Epic_of_Gilgamesh The next post has the "point-free" pipline pattern which is both useful and hard to find out about! hist() { sort | uniq -c | sort -n -r; } Pipelines Support Vectorized, Point-Free, and Imperative Style http://www.oilshell.org/blog/2017/01/15.html http://www.oilshell.org/blog/2017/01/15.html
- loopz 7y agoScripts using ksh/bash are not very maintainable. If it's something simple that just works and never need to change, it's a really good RAD tool. It's good for initiating jobs or do stuff in between. Anything complex, will require looking up some arcane syntax, which the next person or you in 2 years, won't understand what actually does. So will you notice subtle bugs or be able to upgrade or fix the code? The result will be bitrot or adding complexity. The nice things with shell scripts is how fast you can pipe something through UNIX, and it's really really powerful. But regard it as temporary or throw-away code, unless it's just meant to sit there doing the same job, with the same subtle bugs that you won't notice if it's anything more complex.