Skip to content
Snippets Groups Projects
Commit e433e533 authored by Claus-Justus Heine's avatar Claus-Justus Heine
Browse files

Initial revision.

parent 5a7b8186
No related branches found
No related tags found
No related merge requests found
#! /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.$$ <<EOF
#! /bin/sh
F=\$1
if ! echo \$F|grep -iqs "/CVS/" && \\
! grep -iqs alberta \$F && grep -iqs albert \$F ; then
echo "ALBERT -> 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.$$ <<EOF
#! /bin/sh
F=\$1
if ! echo \$F|grep -iqs "/CVS/" && grep -iqs alberta \$F ; then
echo "ALBERTA -> 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.$$ \{\} \;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment