2 ms·
I keep thinking "maybe I should have learned awk"... but I can do all of these things but the line numbering in sed (and there is a standard unix tool for line
by saurik 6y ago
I keep thinking "maybe I should have learned awk"... but I can do all of these things but the line numbering in sed (and there is a standard unix tool for line numbering called nl); it also feels like I might should have learned perl if I wanted this kind of power (but instead I made the "mistake" of getting very very good at sed).
As someone who speaks sed I thereby found this part super confusing:
> In this manner I used it as a kind of modified sed which only operates on certain lines.
But... sed already does that, with the same syntax even? (Note that I don't have BSD sed handy... I would normally use \0, but that & works fine in gsed.)
> awk '/^\/\// { gsub(/\[[a-zA-Z:]+\]/, "[&]") } { print $0 }'
> sed -e '/^\/\// { s/\[[a-zA-Z:]\+\]/[&]/g; }'