Learning awk is actually pretty simple. For years I just used the '{print $2}' version to extract fields, but after reading some short book I felt pretty confident of having understood the basics. Sadly I don't remember which book it was, but this page looks like a good start: https://ferd.ca/awk-in-20-minutes.html
Awk: The Power and Promise of a 40-Year-Old Language
81–90 of 122 posts
Re: Awk: The Power and Promise of a 40-Year-Old Language
#82HN discussion threads for some of the links mentioned in the article: * Using AWK and R to parse 25TB - https://news.ycombinator.com/item?id=20293579 * Command-line Tools can be 235x Faster than a Hadoop Cluster - https://news.ycombinator.com/item?id=17135841 * The State of the AWK - https://news.ycombinator.com/item?id=23240800 For awk alternative implementations, I'm keeping an eye on frawk [0]. Aims to be faster,…
https://www.gnu.org/software/gawk/manual/html_node/Splitting...
https://github.com/e36freak/awk-libs/blob/master/csv.awk
https://raw.githubusercontent.com/Nomarian/Awk-Batteries/mas...
Re: Awk: The Power and Promise of a 40-Year-Old Language
#83Earlier quoted context omitted.
I'm curious what linux distros don't have either some version of perl or python. I like awk, mind, but this is not necessarily (IME) a good argument for it.
> I'm curious what linux distros don't have either some version of perl or python. I imagine that DamnSmallLinux or TinyCoreLinux possibly don't have them by default. Their focus is to be as small as possible in order to download quickly and fit in a USB drive or CD. Their small size was more important back when speeds were slower and drives were smaller. They were also good for when you had a limited number of stora…
Re: Awk: The Power and Promise of a 40-Year-Old Language
#84Earlier quoted context omitted.
Python definitely not, though.
Yeah, but if you are happy to program in Perl, that's basically every major Linux distro covered. Anything using DEB or RPM packaging, any machine with Git installed (which includes Windows), plus the ones I already mentioned, already have access to Perl. This is a formidable installed base with no effort needed to install a runtime.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#85Earlier quoted context omitted.
> I'm curious what linux distros don't have either some version of perl or python. I imagine that DamnSmallLinux or TinyCoreLinux possibly don't have them by default. Their focus is to be as small as possible in order to download quickly and fit in a USB drive or CD. Their small size was more important back when speeds were slower and drives were smaller. They were also good for when you had a limited number of stora…
If you’re using DamnSmallLinux etc I’d imagine you can package your own awk quite easily! Perl would require a lot more packages. But all you need to do is copy a couple binaries right?
Not sure why I'd have to package awk. Busybox's is probably sufficient for most uses, if the need ever arised, which I don't think it normally does when using these distros.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#86I use awk constantly in bioinformatics, for many of the file formats designed to store genomic data, awk is the easiest tool you can use for processing.
quickly looking at averages/errors, a simple awk one-liner will do.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#87Earlier quoted context omitted.
I had to take large CSV files like {question, right_ans, wrong_ans1, wrong_ans2, wrong_ans3} and covert them into SQL insert files. Few caveats - some could be duplicates, some characters were not allowed, and some had formatting issues. The first issue was avoided by upserting, but the other two I used Awk and Sed for and put together a fairly robust script far quicker than if I reached for Python. I probably would…
Awk is not really very good at reading complex CSVs (as defined in RFC-4180), where newlines (record separators) can appear within quoted strings. It can be done, but sometimes it's tricky. The PHP fgetcsv function has been more convenient when I have had more exotic examples. If the CSV is simple, awk remains a very good tool.
https://raw.githubusercontent.com/Nomarian/Awk-Batteries/mas...
Re: Awk: The Power and Promise of a 40-Year-Old Language
#88Earlier quoted context omitted.
If you’re using DamnSmallLinux etc I’d imagine you can package your own awk quite easily! Perl would require a lot more packages. But all you need to do is copy a couple binaries right?
Haven't used these distros since a decade or so ago. Not sure why I'd have to package awk. Busybox's is probably sufficient for most uses, if the need ever arised, which I don't think it normally does when using these distros.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#89Learning awk is actually pretty simple. For years I just used the '{print $2}' version to extract fields, but after reading some short book I felt pretty confident of having understood the basics. Sadly I don't remember which book it was, but this page looks like a good start: https://ferd.ca/awk-in-20-minutes.html
Likely the one by A, W, and K. https://news.ycombinator.com/item?id=13451454
Re: Awk: The Power and Promise of a 40-Year-Old Language
#90Earlier quoted context omitted.
I'm curious what linux distros don't have either some version of perl or python. I like awk, mind, but this is not necessarily (IME) a good argument for it.
The POSIX specification includes awk, but not perl or python. The world of UNIX and UNIX-likes is larger than just Linux distributions. Depending on the utility you plan on building and the platforms you expect it to run on, it may be wiser to reach for awk than other PLs.
Linux distros based on busybox, as mentioned elsewhere in this thread, are a more compelling reason for considering awk than considerations involving other Unixes.