Linux, programming, computers and life

September 9, 2007

more awk examples

Filed under: CLI, programming, awk

As i already mentioned, awk is great. More examples in this post.
Print every n’th line (n=15):
seq 1 100 | awk 'NR%15==0 {print $0}'
Print only n’th line (n = 10):
seq 1 100 | awk 'NR==10 {print $0}'
Print average value:
seq 1 10 | awk '{sum+=$1} END {print sum/NR}'

Feel free to try this at ~ :)

Technorati Tags: , , ,

Comments »

The URI to TrackBack this entry is: http://linux4all.blogsome.com/2007/09/09/more-awk-examples/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.

Get free blog up and running in minutes with Blogsome
Theme designed by Gary Rogers