3 ms·
I learned from the article that one can assign to the dollar vars like: $0="bye bye input line" It seems like this could be a bit of a footgun!? I'm sure it m
by danwills 2y ago
I learned from the article that one can assign to the dollar vars like:
$0="bye bye input line"
It seems like this could be a bit of a footgun!? I'm sure it must be helpful in some cases though! Has anyone used it? Could you share the use-case to help me understand this weird superpower?
- disgruntledphd2 2y agoThis is a terrible, no good, very bad idea, which is probably really useful. It's rather like using awk for stuff that covers more than 10+ lines unless you really, really have to.
- danwills 2y agoThanks, hehe yeah it does seem a bit like writing over the inputs isn't really a great plan in general, except in rare cases where it's a total escape-hatch! (probably amazingly useful then!) I think I mostly agree about the 10+ lines thing although I think I've written things nearly 20 lines (that aren't that crazy!) However there's that undergraduate AI course from 1997 that used it! They would've had loads of lines there I reckon! The original url has rotted now, but here it is on archive.org: https://web.archive.org/web/20140731042732/http://www.wra1th.plus.com/awk/awkfri.txt https://web.archive.org/web/20140731042732/http://www.wra1th...