For all files in this directory, change internal variable $REPLACEMENT to $REPLACEMENT ALSO rename the original files to .original perl -i.original -pe 's/\$REPLACEMENT/\$REPLACEMENT/g' * Same as above but without retaining the original files: perl -i -pe 's/\$REPLACEMENT/\$REPLACMENT/g' * The -p means to enclose your Perl program in a print loop that looks SOMEWHAT like this: while ($_ = <>) { print "$_"; } Remember to diff your original and replacement files to make sure the outcome is what you expected.... OOOOOPPPPPSSS!!!!! What do you do if you made a mistake? simple mkdir REVERT_ME cp -a *.original REVERT_ME cd REVERT_ME # rename files from .original to perl -e 'while(<*.original>){$_=~/(.*)\.original/; rename$_,$1}' Now, just replace the files in the original subdirectory with the files in the REVERT_ME subdirectory.