4 ms·
I don't mind AWK for super simple things, but there is a reason why the sysadmins from the Bad Old Days(tm) who now have grey beards all converged to Perl. Pra
by bsder 4y ago
I don't mind AWK for super simple things, but there is a reason why the sysadmins from the Bad Old Days(tm) who now have grey beards all converged to Perl.
Practically everything you can do in AWK can be done just as easily and quickly in Perl. And Perl absolutely wins when you need to do that one extra thing that AWK really just can't do.
And I say this as a person who switched over from Perl to Python eons ago.
- doctor_eval 4y agoWe didn’t all converge to perl. Some of us avoided it like the plague. I saw some reference to CPAN recently and it made me feel… uncomfortable. Whatever things I couldn’t do in sh or Awk, I would do in C.
- dale_glass 4y agoGood lord, why? Seriously, Perl is an okay language for quick and dirty things of a tiny/small size. Yeah, it's not the best language for a large development project, but if you do need to parse /etc/passwd or something, not only it's perfectly good as-is, but you'll certainly find something on CPAN that already does it well. I can't imagine why would one want to do that kind of thing in C. It's just unnecessarily painful, and you'll spend 90% of the time on doing things that don't solve the actual task you need to be solved. Yeah, in modern times it's gone way downhill, but that's mostly if you intend to do something big with it. I wouldn't use it to start a new, fully featured CMS. But for sysadmin type stuff as an alternative to sh/awk it's still just as usable as ever.
- doctor_eval 4y agoI know loads of people loved Perl, and I'm not suggesting that my perspective is mainstream or even defensible. I'm just saying that I was a young sysadmin in the "bad old days", but that I didn't like Perl. Of course I did use an awful lot of Perl scripts. That said, I have to revise my original comment. I forgot that I was a big fan of Tcl/Tk/Expect back in the day. So it's not like my taste is better than anyone else's :)
- sramsay 4y agoGreybeard here. Just blogged about this very topic a couple of weeks ago: “The Unreasonable Effectiveness of Awk” https://stephenramsay.net/posts/unreasonable-awk.html https://stephenramsay.net/posts/unreasonable-awk.html
- doctor_eval 4y agoNice! You could also use BEGIN { FS = “: “ } Which sets the field separator. This would put the keywords into $2 and remove the need for the gensubs :)
- MrVandemar 4y agoIn both your essays, you have some text surrounded by square brackets: are these intentded to render out as hyperlinks?
- sramsay 4y agoYes. Are they not!?
- MrVandemar 4y agoThey are now. Some of them weren't. Maybe it was a local error for me. Or maybe PEBCAK. Anyway, cool blog. I'm reading it.
- sargstuff 4y agoPerl doesn't work so well with /etc stuff. when /usr, /usr/local, /opt aren't available.