#! /bin/sh # # Don't use a for loop, the number of files might exceed the # command-line limit. # # This script changes albert to alberta and ALBERT to ALBERTA # in _any_ regular file. # # ECHO= while test $# -gt 0 ; do case $1 in DRYRUN) set -x ECHO=echo ESC=\\ ;; REVERSE) REVERSE=1 ;; LIST) LIST=1 ;; *) echo "The arguments must be DRYRUN, REVERSE or LIST" exit 1 ;; esac shift done trap "rm -f /tmp/changesex.$$" 0 if test -z "$REVERSE"; then cat > /tmp/changesex.$$ < ALBERTA in \$F" if test -z "$LIST"; then $ECHO sed -e 's/albert/alberta/g' -e 's/ALBERT/ALBERTA/g' \$F $ESC> \$F.new $ECHO mv -f \$F.new \$F fi fi EOF else cat > /tmp/changesex.$$ < ALBERT in \$F" if test -z "$LIST"; then $ECHO sed -e 's/alberta/albert/g' -e 's/ALBERTA/ALBERT/g' \$F $ESC> \$F.new $ECHO mv -f \$F.new \$F fi fi EOF fi chmod +x /tmp/changesex.$$ find . \( -type f -a \! \( -name "*.new" -o -name ".*.new" \) \) -exec /tmp/changesex.$$ \{\} \;