AWK to print every nth line from a file

前端 未结 3 766
隐瞒了意图╮
隐瞒了意图╮ 2021-01-04 18:41

i want to print every Nth line of a file using AWK. i tried modifying the general format :-

awk \'0 == NR % 4\' results.txt

to:-



        
3条回答
  •  感动是毒
    2021-01-04 18:48

    This do also work, but its not a good practice.

    awk '!(NR%'$ct')' results.txt
    

    This is ok to use:

    awk '!(NR%n)' n="$ct" results.txt
    

提交回复
热议问题