I want a Perl one. I never saw the need to do AWK because I knew Perl fairly well. In saying that the youngsters should learn some of these old school tools. Python is a nice language but the regexes are crap acompared to Perl. I always need to look up the documentation. Perls are built in, clean and concise. (caturing, groups) = string =~ /regex/ I remember that having not touched Perl in a while. I miss it.
Have yet to learn Perl, but I've frequently not seen it preinstalled on systems, and additionally you sometimes need CPAN to be able to run scripts. awk might not be as powerful, but at least you know it's small, self-contained, and likely to be available in some form on most systems. That's part of its value I think... likely a consequence of not trying to do as much.
Show HN: An eBook with hundreds of GNU Awk one-liners
41–50 of 51 posts
Re: Show HN: An eBook with hundreds of GNU Awk one-liners
#42I want a Perl one. I never saw the need to do AWK because I knew Perl fairly well. In saying that the youngsters should learn some of these old school tools. Python is a nice language but the regexes are crap acompared to Perl. I always need to look up the documentation. Perls are built in, clean and concise. (caturing, groups) = string =~ /regex/ I remember that having not touched Perl in a while. I miss it.
Re: Show HN: An eBook with hundreds of GNU Awk one-liners
#43I have the Bash equivalent (sorta) on my bookshelf and has seen a lot of use. ('GNU Introduction to the Command-Line').
It introduces a command, describes the options in detail, and then the next few pages for each command are useful bash (mostly) one-liners.
Re: Show HN: An eBook with hundreds of GNU Awk one-liners
#44Thank you, even if publishing it at this time was somewhat Awk-ward...
Re: Show HN: An eBook with hundreds of GNU Awk one-liners
#45I want a Perl one. I never saw the need to do AWK because I knew Perl fairly well. In saying that the youngsters should learn some of these old school tools. Python is a nice language but the regexes are crap acompared to Perl. I always need to look up the documentation. Perls are built in, clean and concise. (caturing, groups) = string =~ /regex/ I remember that having not touched Perl in a while. I miss it.
Re: Show HN: An eBook with hundreds of GNU Awk one-liners
#46I want a Perl one. I never saw the need to do AWK because I knew Perl fairly well. In saying that the youngsters should learn some of these old school tools. Python is a nice language but the regexes are crap acompared to Perl. I always need to look up the documentation. Perls are built in, clean and concise. (caturing, groups) = string =~ /regex/ I remember that having not touched Perl in a while. I miss it.
It takes way less time to learn awk than perl.
Re: Show HN: An eBook with hundreds of GNU Awk one-liners
#47I always like when classic lean-and-mean Unix tools get attention, as opposed to big language ecosystems. Speaking of which, is there a particular reason why only gawk is covered? gawk has only very minor enhancements to POSIX awk, and gawk isn't even the default in many place. For example, Debian uses, or used to use, mawk as default, while the BSDs and Mac OS have nawk. I think the point of awk is that it's portabl…
Agree about portability issues. I cover only gawk, because I don't know all the differences between various versions. This started as a chapter in my command line text processing repo, where I cover various tools. I had come across various posts on stackoverflow/unix.stackexchange about implementation differences. I use Ubuntu, so I made a choice of sticking to GNU/Linux to make my life simpler. I'm not sure about yo…
https://pubs.opengroup.org/onlinepubs/009695399/utilities/aw...
Here’s my AWK (OK, shell + AWK) one liner:
while echo -n '] ' ; do read a; awk 'BEGIN{print '"$a"'}' ; done
It’s a calculator; type in something like 2 + 2 and it will give you 4. Since standard AWK has advanced math functions like log, it’s a full blown scientific calculator.The only tricky part is that you hit Ctrl + C (not Ctrl + D) to exit it.
Re: Show HN: An eBook with hundreds of GNU Awk one-liners
#48I always like when classic lean-and-mean Unix tools get attention, as opposed to big language ecosystems. Speaking of which, is there a particular reason why only gawk is covered? gawk has only very minor enhancements to POSIX awk, and gawk isn't even the default in many place. For example, Debian uses, or used to use, mawk as default, while the BSDs and Mac OS have nawk. I think the point of awk is that it's portabl…
Debian Stable runs GNU Awk. Issuing the command awk --version gives the output: GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)
Re: Show HN: An eBook with hundreds of GNU Awk one-liners
#49I always like when classic lean-and-mean Unix tools get attention, as opposed to big language ecosystems. Speaking of which, is there a particular reason why only gawk is covered? gawk has only very minor enhancements to POSIX awk, and gawk isn't even the default in many place. For example, Debian uses, or used to use, mawk as default, while the BSDs and Mac OS have nawk. I think the point of awk is that it's portabl…
I don't see Unix tools as lean and mean, but as brittle and slow. It's never just a "one liner", you end up piping text data through dozens of programs with inconsistent unstructured interfaces. I don't understand the reverence for these tools. I think it's a bunch of junk that somehow can't get replaced because it's not quite bad enough and it's "already installed" everywhere.
Re: Show HN: An eBook with hundreds of GNU Awk one-liners
#50Earlier quoted context omitted.
My claims were that GNU awk is everywhere that awk sees substantial use, and that it runs everywhere. These were two separate claims, and are very different. It is very rare that you see a system that awk is frequently used on that doesn't have GNU awk installed.
> It is very rare that you see a system that awk is frequently used on that doesn't have GNU awk installed. Wait, what? Ubuntu server and macOS both have awk preinstalled (which is true for any POSIX) and gawk not preinstalled. Those are what I (and many other developers) spend 95% of my time on. And I do use awk frequently. Edit: Okay, /usr/bin/awk is actually gawk on Ubuntu, so I was wrong about that. Still, macOS…