Perl, Extended Find and Replace

Use with caution, this will not make backups:

search="searchRegExp"
replace="replaceStr"
egrep -lri --exclude="Entries" --exclude="*.gif" --exclude="*.WAV" --exclude="*.wav" --exclude="*.zip"  "$search" * | xargs perl -pi -e "s/$search/$replace/gi"

the “gi” option means globally, case-insensitive, so take the “i” off if you want it to be case-sensative.

If you want to make backup files, replace “perl -pi” with “perl -pi.bak”

Dave.

Comments are closed.