There are a lot of files without patterns and running them all through
sed is quite slow. Using grep first makes this quicker (about 0.5s per
test). Ignoring PEM files is also helpful.
# search and replace in each found file the
# given string
#
-
- for eachfoundfile in `find $DESTDIR -type f`
- do
- sed -i -e "s/$SEARCHSTRING/$REPLACESTRING/g" "$eachfoundfile"
- done
-
+ grep -rlZ --exclude='*.pem' "$SEARCHSTRING" $DESTDIR | \
+ xargs -0 -I@ sed -i -e "s/$SEARCHSTRING/$REPLACESTRING/g" @
}