#!/bin/awk -f # see http://theunixshell.blogspot.de/2014/05/inserting-lines-in-file-using-perl.html { print repl = sprintf("%d\"", (NR - 1) % 3 + 5) print gensub(/.\"$/, repl, 1) }