News for hackers. Stuff that matters.
Re:Understanding Awk by flandish on Thursday September 30, 2021 @12:14PM (#28708039)
A long while ago I wrote up a little processor to determine field lengths in a given file - I forgot the original reason. ( https://github.com/sullivant/csvinfo )

However, I feel I really should have taken the time to learn Awk better as it could probably be done there, and simply! (It was a good excuse to tinker with rust, but that's an aside.)

Re:Understanding Awk by tyingq on Thursday September 30, 2021 @01:08PM (#28708615)
For some idea, a one liner to find the (last) longest username and length in /etc/passwd:

  $ awk -F: '{len=length($1);if(len>max){max=len;user=$1}}END{print user,max}' /etc/passwd
Re:Understanding Awk by flandish on Thursday September 30, 2021 @01:32PM (#28708874)
Thanks for that reply! It's good to work with an example.
Re:Understanding Awk by genewitch on Thursday September 30, 2021 @01:36PM (#28708923)
I'll mark this on my GitHub when I get back on a computer, I take public datasets and make graphs and transforms and reports. The big survey companies have weird data records and having to write a parser is my least favorite part. I think other people who ingest my content don't appreciate the effort, but that's a near universal feeling I think, heh.