perl -ple'BEGIN { print "new text" }' infile > outfile #### perl -i -ple'BEGIN { print "new text" }' file