#!/bin/sed -f # see http://theunixshell.blogspot.de/2014/05/inserting-lines-in-file-using-perl.html # write line unchanged p # change to hold space x # initialize replacement sequence if it wasn't already s/^$/5\"/ # append to original line H # cycle through numbers for next iteration y/567/675/ # change to appended line x # remove old line end s/.\"\n//