You can use:
awk -v patt="$ct" 'NR % patt' results.txt
Explanation
For a file like the following:
$ cat -na 1 hello1 2 hello2 3 hello3 4 hello4 5 hello5 ... 37 hello37 38 hello38 39 hello39 40 hello40
They are equivalent:
$ awk 'NR % 7 == 0' a hello7 hello14 hello21 hello28 hello35 $ ct=7 $ awk -v patt="$ct" 'NR % patt == 0' a hello7 hello14 hello21 hello28 hello35
Or even
$ awk -v patt="$ct" '!(NR % patt)' a
Note that the syntax NR % n == 0 means: the number of lines is multiple in n . If we say !(NR % patt) , then this is true when NR % patt is false, i.e. NR is a multiple of patt .
Update
As you comment, you are using Solaris instead of the standard awk use the following:
/usr/xpg4/bin/awk
fedorqui
source share