cat file1 echo --- cat file2 #### ... --- perl output to stdout --- line3 opt=bar --- cat after --- line1 line2 --- line3 line1 line2 #### perl -i -pe '$f||=s/opt=.*/opt=bar/; $_.="opt=bar\n" if !$f && !@ARGV && eof' files...