"A good programmer uses the most powerful tool to do a job. A great programmer uses the least powerful tool that does the job." I believe this, and I always try to find the combination of simple and lightweight tools which does the job at hand correctly. Awk sometimes proves surprisingly powerful. Just look at the concision of this awk one liner doing a fairly complex job: zcat large.log.gz | awk '{print $0 | "gzip -…
Ehh. Until the 'job' gets extended and then your simple tool makes it exponentially more complex and you have to rewrite it with the more powerful tool.
Awk: The Power and Promise of a 40-Year-Old Language
71–80 of 122 posts
Re: Awk: The Power and Promise of a 40-Year-Old Language
#72Earlier quoted context omitted.
I don't agree. Awk is very readable for people used to c-like languages like javascript. And it is much cleaner that Perl.
It is certainly more readable than sed for example.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#73I never use Awk until last year. I wanted to monitor an embedded device with little more than bustbox and python on it. There was quite a bit of information in the log files (I had already written a custom log file viewer with some highlighting) but I wanted to monitor in real-time. Somehow I decided to use Awk to monitor the tail of the log file and do realtime bar-graphs by generating appropriate cursor control seq…
The biggest reason to learn AWK, IMO, is that it's on pretty much every single linux distribution. You might not have perl or python. You WILL have AWK. Only the most minimal of minimal linux systems will exclude it. Even busybox includes awk. That's how essential it's viewed.
Python: almost every conventional server. Python dependencies are so ubiquitous that you aren't likely to find a Linux install without it.
Perl: every DEB and RPM machine, and anything with Git installed. You can't really escape it, unless you're embedded.
PowerShell (yeah, I know): every Windows machine from XP onwards (though usable only from 7 onwards), and some Linux computers if installed.
Java: lots and lots of places will have this available.
Dockerized runtime of your choice: not ubiquitous, but I expect more and more developer machines and servers to gain Docker or Docker-like container support.
There really isn't any reason to stick to AWK, unless you're working directly on embedded devices or just like using it.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#74Sadly I don't remember which book it was, but this page looks like a good start: https://ferd.ca/awk-in-20-minutes.html
Re: Awk: The Power and Promise of a 40-Year-Old Language
#75Earlier 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
#76Earlier 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.
You'll find this a lot in the embedded space. As well, you'll see a bunch of docker images that don't have perl/python.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#77Earlier 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…
I don't think I ever ran TinyCore without immediately connecting it to the Internet to grab a bunch of packages. Puppy Linux included Perl in its base install at one time (I don't know if it still does), and Damn Small Linux was supposed to have a cut-down version of Perl included as well.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#78Re: Awk: The Power and Promise of a 40-Year-Old Language
#79Earlier quoted context omitted.
I don't think I ever ran TinyCore without immediately connecting it to the Internet to grab a bunch of packages. Puppy Linux included Perl in its base install at one time (I don't know if it still does), and Damn Small Linux was supposed to have a cut-down version of Perl included as well.
Python definitely not, though.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#80Earlier quoted context omitted.
The biggest reason to learn AWK, IMO, is that it's on pretty much every single linux distribution. You might not have perl or python. You WILL have AWK. Only the most minimal of minimal linux systems will exclude it. Even busybox includes awk. That's how essential it's viewed.
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.
This suggests an opening for a Perl/Python intro focused on the exact same tasks, admittedly. That seems more realistic for Perl -- unless there's someone who writes Python one-liners at the shell?