I only recently learned Awk enough to be useful. But I still don't reach for it when I probably should. What are the most common cases where you reach for Awk instead of some other tools? I recently used it to parse and recombine data from the OpenVPN status file. That file has a few differently formatted tables in the same file. Using Awk, I was able to change a variable as each table was encountered, this I could c…
try running this: awk '{cmd="rm " FILENAME; print cmd; system(cmd) }' file* best results if you do 'sudo' first ymmv
Awk: The Power and Promise of a 40-Year-Old Language
11–20 of 122 posts
Re: Awk: The Power and Promise of a 40-Year-Old Language
#12I only recently learned Awk enough to be useful. But I still don't reach for it when I probably should. What are the most common cases where you reach for Awk instead of some other tools? I recently used it to parse and recombine data from the OpenVPN status file. That file has a few differently formatted tables in the same file. Using Awk, I was able to change a variable as each table was encountered, this I could c…
try running this: awk '{cmd="rm " FILENAME; print cmd; system(cmd) }' file* best results if you do 'sudo' first ymmv
Re: Awk: The Power and Promise of a 40-Year-Old Language
#13Awk 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 -v9c > large.log-"$1"_"$2".gz"}' # Breakup compressed log by syslog date and recompress. #awksome
Taken from: https://mobile.twitter.com/climagic/status/61415389723039744...Re: Awk: The Power and Promise of a 40-Year-Old Language
#14Arguably, the software world would be better off if more people did code with those 1970s languages, than with the ones we are stuck with now.
And that applies to Awk, too. As the author quotes Neil Ormos stating, Awk is well suited for personal computing, something which we have gotten further and further from at the same time as computers have become more distributed. At what point in history have such a large fraction of the human race had the ability to calculate to such an amazing order of magnitude, and at what point in history have such a large fraction of the same human race not bothered with calculation?
Awk is a great tool precisely because it puts quite a lot of expressive power in the hands of an average user on a Unix system. Sure, on a Lisp machine or Smalltalk machine there really isn't the same need for Awk: the systems languages on such machines are safe enough and expressive enough to do what Awk does. But in the Unix context — which is basically what we're all living in, with even the VMS-derived Windows more-or-less adhering to the Unix model — Awk is a godsend.
edit: correct typo
Re: Awk: The Power and Promise of a 40-Year-Old Language
#15I only recently learned Awk enough to be useful. But I still don't reach for it when I probably should. What are the most common cases where you reach for Awk instead of some other tools? I recently used it to parse and recombine data from the OpenVPN status file. That file has a few differently formatted tables in the same file. Using Awk, I was able to change a variable as each table was encountered, this I could c…
Re: Awk: The Power and Promise of a 40-Year-Old Language
#16i no longer use it but Perl was always the better solution when one thought AWK was the answer. Perl will do those things where AWK really shines and if the problem got bigger, Perl was easier to deal with.
Yes but you can't learn perl as quickly as you can learn awk.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#17i no longer use it but Perl was always the better solution when one thought AWK was the answer. Perl will do those things where AWK really shines and if the problem got bigger, Perl was easier to deal with.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#18awk is fast and really useful. It's also generally unreadable.
Re: Awk: The Power and Promise of a 40-Year-Old Language
#19I only recently learned Awk enough to be useful. But I still don't reach for it when I probably should. What are the most common cases where you reach for Awk instead of some other tools? I recently used it to parse and recombine data from the OpenVPN status file. That file has a few differently formatted tables in the same file. Using Awk, I was able to change a variable as each table was encountered, this I could c…
#!/bin/gawk -f
BEGIN { smtp="/inet/tcp/0/smtp.yourhost.com/25";
ORS="\r\n"; r=ARGV[1]; s=ARGV[2]; sbj=ARGV[3]; # /usr/local/bin/awkmail to from subj 0) print |& smtp
print "." |& smtp; smtp |& getline j; print j
print "quit" |& smtp; smtp |& getline j; print j
close(smtp) } # /inet/protocol/local-port/remote-host/remote-port
This allows me to bypass the local MTA (if present). The message ID is also returned, which can be useful to log.