bash - How to extract x lines every y number of lines -


i have big file want extract x lines every y number of lines. searched around , found answers on how print first z lines, tail -n +<lines skip + 1> i'm trying combine sed don't know how.

to print first 2 lines of every tex lines, try:

awk -v x=2 -v y=10 '(nr - 1) % y < x' 

for example:

$ seq 20 | awk -v x=2 -v y=10 '(nr - 1) % y < x' 1 2 11 12 

how works

awk reads through input line-by-line. print line if condition (nr - 1) % y < x true. nr line number starting @ 1 first line.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -