1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#!/usr/bin/env bash
#/***********************************************************************
# Freeciv - Copyright (C) 2017-2023
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#***********************************************************************/
if test "$1" = "-h" || test "$1" = "--help" || test "$3" = "" ; then
echo "Usage: $0 <path> <string to replace> <replace with>"
exit
fi
find "$1" -name "*.[ch]" |
(while read FILE ; do
if grep "$2" "$FILE" >/dev/null ; then
echo "Updating $FILE"
sed "s/$2/$3/g" "$FILE" > "$FILE.new"
mv "$FILE.new" "$FILE"
fi
done )
|