4 ms·
Awk is a viable replacement for Bash for scripting. A long established standard and installed on pretty much every POSIX system. It has more robust facilities f
by dexen 6y ago
Awk is a viable replacement for Bash for scripting. A long established standard and installed on pretty much every POSIX system. It has more robust facilities for handling variables, arrays, regex search & substitution, etc.
- usr1106 6y agoawk is a full programming language. But it has gotten little attention in the last 20 years. If you expect that someone else can read and maintain your code with minimal learning I don't think it's the tool of choice.
- jrochkind1 6y agoBut... neither is bash. I am sympathetic to the argument that awk is theoretically superior to bash in almost all ways (and it is of course nearly as available as bash). But... something still makes me reluctant to switch to using it in the cases I write a bash script (which I'm already trying to minimize, as is the OP). I'm not really sure why though. (Fun-for-mostly-me fact, my very first programming job ever was writing awk. It was a while ago. I certainly don't remember any awk now).
- alexhutcheson 6y agoAwk is great for snippets that are meant to be copy+pasted into a shell, and is the only reasonable option sometimes if you're stuck in a Busybox environment, but for almost everything else you'd be better off with Python. This previous comment of mine goes into a bit more detail: https://news.ycombinator.com/item?id=23242753 https://news.ycombinator.com/item?id=23242753
- fomine3 6y agoAgreed but I point that not all awks are gawk.