3 ms·
Bash, awk et al = the syntax that can't be remembered, not even when smashed in the head with a tiring iron or forced with a submachine gun.
by lofaszvanitt 4y ago
Bash, awk et al = the syntax that can't be remembered, not even when smashed in the head with a tiring iron or forced with a submachine gun.
- stn_za 4y agoIt's easy. You just need to stop thinking of these things as toys... Awk + bash could easily recreate most existing code in a couple of lines
- samuell 4y agoI found the awk syntax to be surprisingly discoverable, once I got the rough structure of scripts. I think the confusing factor with awk is that it allows you to leave out variuos levels of structure in the really simple scripts, meaning that the same scripts you see around will look quite different. E.g. all the following would be the same (looking for the string "something" in column 1, and printing only those lines): '$1 == "somestring"' '$1 == "something" { print }' '($1 == "something")' '($1 == "something") { print }' ... to give a small example. At least this confused me a lot in the beginning.
- wiredfool 4y agoawk '{print $3}' is what cut should have been all along. Specifically, this will give you the third space delimited field, where multiple spaces are coalesced. cut -d ' ' -f 3 will get you whatever is between the 3rd and 4th space.
- hawski 4y agoI can agree on bash syntax being crazy, but certainly not on awk. Awk is very simple, a man page is all you need if you need to find something. Otherwise what's so complex with awk?
- abecedarius 4y agoIf you don't like learning from a man page (understandable), I can recommend a quick read of the Awk book by A, K, and W. It's very short and has fun examples.
- nice2meetu 4y agoI feel there was a missed chance to make it “by A, W and K”
- tannhaeuser 4y agoAwk syntax is basically what became core Javascript according to its creator [1]. Bourne shell syntax is very different so I take your comment as a frustrated reaction to the "Python obsolete" comment which must be seen in context with Python introducing itself as an awk replacement among other things (though not nearly as aggressive as Perl which use to have the a2p script to bogusly convert awk to Perl code). [1]: https://brendaneich.com/2010/07/a-brief-history-of-javascript/ https://brendaneich.com/2010/07/a-brief-history-of-javascrip...
- asdff 4y agoBash is so comfortable to write in, its like you are just writing psuedocode. Pipes >>>>>>> a dozen parentheses I forget to close half the time.