Awk is Amazing

Without a doubt, Awk is beautiful.

I’ve been neglecting linux now for about the past 2 years, after spending 10 years pursuing it with much passion; and I was again reminded of why I enjoyed linux. It was the continual problems, and experiences the highs of solving them. Bearing that in mind, there are too many problems in that space and now  I just prefer Windows for it’s focus away from the OS to the application – in this case my IDE.

That’s a bit of a tangent, but coming back to Awk; I am reminded of how powerful it is, and how Windows lags behind in having this kind of power on the command line (natively).

 

# Print disk stats from the third field

cat /proc/diskstats | awk ‘{ print substr($0, index($0,$3))}’

# Print disk stats of those whose last field is not zero

cat /proc/diskstats | awk ‘$NF != 0’

*sigh*
~ ooooh
for i in `cat /proc/diskstats | awk ‘$NF != 0’ | awk ‘{ print substr($0, index($0,$3))}’`; do echo $i; done
Just what I needed šŸ˜‰

 

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

Leave a Reply