BUG: potentialFoam/cylinder: indexing into non-existing patch in parallel
[OpenFOAM-2.0.x.git] / bin / tools / inlineReplace
blob27d19f8164984cc6df4a4cea9e96690fe15a4127
1 #!/bin/sh
3 # $0 oldString newString file1 .. fileN
5 if [ $# -lt 3 ]
6 then
7 echo "Usage: ${0##*/} <oldString> <newString> <file1> [.. fileN]"
8 echo ""
9 echo "Replaces all occurrences of oldString by newString in files."
10 echo "(replacement for sed -i on systems that don't support it)"
11 exit 1
14 oldString="$1"
15 newString="$2"
16 shift 2
18 for f
20 if grep "$oldString" "$f" >/dev/null
21 then
22 cp "$f" "${f}_bak"
23 sed -e "s@$oldString@$newString@g" "${f}_bak" > "$f"
24 rm -f "${f}_bak"
25 #else
26 # echo "String $oldString not present in $f"
28 done
30 # ----------------------------------------------------------------- end-of-file