mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
Add the OpenFOAM source tree
This commit is contained in:
30
bin/tools/inlineReplace
Executable file
30
bin/tools/inlineReplace
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
# $0 oldString newString file1 .. fileN
|
||||
#
|
||||
if [ $# -lt 3 ]
|
||||
then
|
||||
echo "Usage: ${0##*/} <oldString> <newString> <file1> [.. fileN]"
|
||||
echo ""
|
||||
echo "Replaces all occurrences of oldString by newString in files."
|
||||
echo "(replacement for sed -i on systems that don't support it)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
oldString="$1"
|
||||
newString="$2"
|
||||
shift 2
|
||||
|
||||
for f
|
||||
do
|
||||
if grep "$oldString" "$f" >/dev/null
|
||||
then
|
||||
cp "$f" "${f}_bak"
|
||||
sed -e "s@$oldString@$newString@g" "${f}_bak" > "$f"
|
||||
rm -f "${f}_bak"
|
||||
#else
|
||||
# echo "String $oldString not present in $f"
|
||||
fi
|
||||
done
|
||||
|
||||
# ----------------------------------------------------------------- end-of-file
|
||||
Reference in New Issue
Block a user