Need to change this script so it does not change date or permissions of file edited/copied.
and if possible- if file is being used by another process - do not touch and move on to next file.
Decription: change text within multiple files
:
# chtext - change text within multiple files
if [ $# -lt 3 ]
then
echo >&2 "usage: chtext old new [file ...]"
exit 1
fi
Old="$1"
New="$2"
shift; shift
for file
do
echo >&2 "chtext: change $file: $Old to $New"
if [ -r "$file" ]
then
if sed "s|$Old|$New|g" < "$file" > /tmp/ct$$
then
mv /tmp/ct$$ "$file"
else
echo >&2 "chtext: could not change file: $file"
fi
fi
done
and if possible- if file is being used by another process - do not touch and move on to next file.
Decription: change text within multiple files
:
# chtext - change text within multiple files
if [ $# -lt 3 ]
then
echo >&2 "usage: chtext old new [file ...]"
exit 1
fi
Old="$1"
New="$2"
shift; shift
for file
do
echo >&2 "chtext: change $file: $Old to $New"
if [ -r "$file" ]
then
if sed "s|$Old|$New|g" < "$file" > /tmp/ct$$
then
mv /tmp/ct$$ "$file"
else
echo >&2 "chtext: could not change file: $file"
fi
fi
done