db7fac3f24
git-svn-id: https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Core/OpenFOAM-1.5-dev@1731 e4e07f05-0c2f-0410-a05a-b8ba57e0c909
28 lines
610 B
Bash
Executable file
28 lines
610 B
Bash
Executable file
#!/bin/sh
|
|
|
|
# $0 string1 string2 file1 .. filen
|
|
#
|
|
if [ $# -lt 3 ]; then
|
|
echo "Usage: `basename $0` [-f] <string1> <string2> <file1> .. <filen>"
|
|
echo ""
|
|
echo "Replaces all occurrences of string1 by string2 in files."
|
|
echo "(replacement of sed -i on those systems that don't support it)"
|
|
exit 1
|
|
fi
|
|
|
|
FROMSTRING=$1
|
|
shift
|
|
TOSTRING=$1
|
|
shift
|
|
|
|
for f in $*
|
|
do
|
|
if grep "$FROMSTRING" "$f" >/dev/null
|
|
then
|
|
cp "$f" "${f}_bak"
|
|
sed -e "s@$FROMSTRING@$TOSTRING@g" "${f}"_bak > "$f"
|
|
rm -f "${f}"_bak
|
|
#else
|
|
# echo "String $FROMSTRING not present in $f"
|
|
#fi
|
|
done
|