How do I print every 10th line of a file from UNIX shell (grep, awk, sed) ???

How do I print every 10th line of a file from UNIX shell.

I need a grep/awk/sed command which can help me print every nth line of a huge netflow data which I am trying to sample
Shivam_pAsked:
Who is Participating?
 
peter991Connect With a Mentor Commented:
If you want the first line as nr one and then count 10 steps ahead and print every 10:th line.

$> sed -n '1,${p;n;n;n;n;n;n;n;n;n;}' file

If you want to start at line 10.

$> sed -n '10,${p;n;n;n;n;n;n;n;n;n;}' file
0
 
ozoCommented:
awk 'NR%10==0'  file
0
 
Shivam_pAuthor Commented:
Thanks buddy.... that was precisely I was looking for !!
0
 
ozoCommented:
If you want to start at line 1

awk 'NR%10==1'
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.