Something like that:
for ((i=1; i<6; i++)) do head -n$i test.txt done
Please note that I ran the variable i in 1 so that we would not get an error from head (for example: head: illegal line count -- 0 ). And you can access the variable i using $i in your loop.
source share