I am new to AWK.
I have a large text file (> 3 GB). How to use the AWK line command to extract / print selected lines (lines # 62, # 152 and 153) in this order and iterate every 217 lines until the end of the file entry.
Tried to search and learn online. Tried below and it doesn't work,
awk '{(for (i=62; i<=NR; i=i+217)||for (i=62; i<=NR; i=i+217)||for (i=62; i<=NR; i=i+217)); print}' file.txt
and
count=62||152||153 awk '{if (++count%217==0) print;}' file.txt
Could you give me some pointers or lead me to any network that could help.
I use this http://www.catonmat.net/blog/wp-content/uploads/2008/09/awk1line.txt to find out.
Rgds Saravanan K
Update # 1 - September 21, 2012 - 10.40pm
I tried
awk 'NR == 62 || NR == 152 || NR == 153 || NR % 217 == 0 {print $0;}' file.txt
Ability to print lines # 62, # 152 and # 153, but not all of the following iterations, for example, # (62 + 217), # (152 + 217) and # (153 + 217), etc.
Tried and below, but it does not work well.
awk '(NR == 62 || NR == 152 || NR == 153) && (((NR-62) % 217==0) || ((NR-152) % 217 ==0)|| ((NR-153) % 217==0)) {print $0;}' file.txt
Update # 2 - September 21, 2012 - 10.55pm - CLOSED
I tried the rmunoz idea with some tweaking. He worked like magic. Thanks for rmunoz, with this I close this topic
awk '(NR - 62) % 217 == 0 || (NR - 152) % 217 == 0 || (NR - 153) % 217 ==0 {print $0;}' file.txt