perl -MFile::Copy -e 'for(@ARGV){ $a=$_; s/FOO/BAR/; move($a,$_) }' *FOO*