3 ms·
Say i want to print the Nth column of programs output how easy it is compared to awk?
by throwaway5486nv 5y ago
Say i want to print the Nth column of programs output how easy it is compared to awk?
- ajross 5y agoHeh, sure: perl -ne 'print((split())[1])' While it's true that "{print $2}" is a little shorter, it's also quite limited. The perl syntax extends naturally to different delimeters (the first argument to split is a regex) or actions (maybe you don't want to print it and want to do some tiny string processing). Essentially, you picked the One Single Task at which awk is best. And... it's only barely better, and only for the specific variant of the problem for which awk was designed. Again, this argument was had and settled. No one in their right mind would have been caught writing an awk script in 1997. That doesn't mean awk is bad (it's software from the mid-70's!), it means it was superceded. And it's important for people interested in those sorts of problems to understand why it got replaced.