Earlier quoted context omitted.
PERL is bloatware by comparison and less likely to be installed on distros than AWK. (e.g, embedded or slim distros. that's why you rarely see nonstandard /bin execs in shell scripts).
The awk on an embedded system is most likely a non-mainstream awk implementation with fewer or different features.
Why Learn Awk? (2016)
101–110 of 246 posts
Re: Why Learn Awk? (2016)
#102Last week I threw out AWK and replaced it with Ruby (Could've been Python, Perl or PHP even). Because AWK is not suited for CSV. Please prove me wrong! I had to parse 9million lines. Some of which contain "quoted records", others, same column, are unquoted. Some contain comma's, in the fields, most don't. CSV is like that: more like a guideline than actual sense. Two hours of googling and hacking later, I gave up and…
Re: Why Learn Awk? (2016)
#103Because for some bizarre reason, "cut" doesn't ship with any decent column selection logic that is the equivalent of awk's $1, $2, etc., even in 2020. That's like 90% of my use of awk right there. I don't know of any easier equivalent of "awk '{ print $2 }'" for what it does. Posted partially so the Internet Correction Squad can froth at the mouth and set me straight, because I'd love to be showed to be wrong here.
I define aliases c1, c2, c3, c4, etc. in my .bashrc as "awk '{print $1}'" etc. But it's nice to have awk for the slightly more complicated cases, up until it's easier to use Python or another language.
Re: Why Learn Awk? (2016)
#104Earlier quoted context omitted.
The awk on an embedded system is most likely a non-mainstream awk implementation with fewer or different features.
Proof? Or are you just guessing?
Every commercial embedded Linux product that I've seen uses Busybox (or maybe Toybox) to provide the coreutils. If awk is available on a system like that, it's almost certainly Busybox awk.
And Busybox awk is fine for a lot of things. But it's definitely different than GNU awk, and it's not 100% compatible in all cases.
Re: Why Learn Awk? (2016)
#105I gave awk a sincere attempt, but I have to say that it wasn't worth it. As soon as one tries to write anything bigger than a one liner the language shows its warts.. I found myself writing lots of helper routines for things that should be part of the base language/library, e.g. sets with existence check. I also had to work around portability issues, because awk is not awk, unlike this post claims. E.g. matching a pa…
You realize AWK is about 1/100th the size of Python, right? That's like comparing a Leatherman multi-tool to a Craftsman 2000 piece tool set that weighs 1,000 lbs. This matters significantly when addressing compatibility and when building distros that are space constrained. Awk is there for a reason: to be small. That's why the O'Reilly press book is called "Sed & Awk", because they were orignally written to work tog…
The only reason I could've seen to use awk was to throw code together more quickly in a DSL.
However this is much less the case than I had hoped. For the one liners there are usually specialized tools like fex that are easier to use and faster (for batch processing).
When I compared my C/python/awk programs the difference was msec/sec/minutes. As soon as I use such a program repeatedly it starts to hurt my productivity. And the development time is not orders of magnitude slower in non-awk languages.
Re: Why Learn Awk? (2016)
#106Contact information is hn handle @ yahoo.com.
Re: Why Learn Awk? (2016)
#107Last week I threw out AWK and replaced it with Ruby (Could've been Python, Perl or PHP even). Because AWK is not suited for CSV. Please prove me wrong! I had to parse 9million lines. Some of which contain "quoted records", others, same column, are unquoted. Some contain comma's, in the fields, most don't. CSV is like that: more like a guideline than actual sense. Two hours of googling and hacking later, I gave up and…
Re: Why Learn Awk? (2016)
#108Earlier quoted context omitted.
The awk on an embedded system is most likely a non-mainstream awk implementation with fewer or different features.
Proof? Or are you just guessing?
Re: Why Learn Awk? (2016)
#109As an example, if I want a sorted list of all open files under the home directories on CentOs I can do this:
lsof | awk '{ print $10 }' | grep ^/home/ | sort | uniq
Re: Why Learn Awk? (2016)
#110I believe this was intentional by the authors.
In the early days of UNIX, I think more of its users knew C. Today, it is probably a much smaller number. However, learning AWK today, IMO, can help someone who also intends to learn C.