Unix: perl -i.bak -pe 'print "a test content\n\n" if $.==4' a.txt Windows: perl -i.bak -pe "print qq{a test content\n\n} if $.==4" a.txt