Afficher un message
Vieux 24/08/2006, 15h11   #1
pedromalves@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Sed Find and Replace Multiple Files

I'm trying to do search/replace on multiple text files.
I'm using the following script:

#!/bin/sh
USAGE=`basename $0`
USAGE=$USAGE' <PATTERN> <SUBSTITUTE> <FILES PATH>'
if test $# -lt 3
then
echo "-I-: $USAGE"
exit 1
fi
PATTERN=$1
shift
SUBSTITUTION=$1
shift
for i;
do
mv $i $i.old;
sed -e 's/$PATTERN/$SUBSTITUTION/g' $i.old > $i;
done
\rm *.old

What happens is that if I echo the commands out to the shell and
execute them, the replacement will occur as expect. If I run to script
to execute the sed command, the resulting output will not have any
change.

Can someone please me understand this?

Thanks in advance,
Pedro Alves

  Réponse avec citation
 
Page generated in 0,04304 seconds with 9 queries