perl -pe 'END{print "XXX"} s/^/XXX\n/' file perl -ple 'END{print "XXX"} print "XXX"' file perl -lane 'END{print "XXX"} print "XXX\n$F[0]"' file