J'ai écrit ça: avec un fichier d'entree "entree.csv" (voir plus bas)
IFS="!"
if [ $# -lt 1 ]
then
echo "nom du fichier[.csv]"
exit
fi
for lg in `cat $1`
do
Code=`echo $lg | awk -F";" '{ printf "%s", $1 }'`
Chaine = `echo $lg | awk -F";" '{ printf "%s", $2 }'`
Fichier=`echo $lg | awk -F";" '{ printf "%s", $3 }'`
cat $Fichier | while read theline
do
echo "$theline" >> titi
if [ "$theline" = "Insert Into DISCOUNT_RESTRICTIONS Values ("$Code", 5, 3, 15, 0)" ]
then
echo "Insert Into DISCOUNT_RESTRICTIONS Values ("$Code", "$Chaine)" >> titi
fi
done
done
mv titi $Fichier
----------------------------------------------------------------------
fichier d'entree "entree.csv"
26231; 5,3,93,0;g041000.sql;!
27753; 5,3,93,0;g041000.sql;!
26233; 5,3,93,0;g041001.sql;!
27754; 5,3,93,0;g041001.sql;!
26235; 5,3,93,0;g041002.sql;!
27755; 5,3,93,0;g041002.sql;!
26237; 5,3,93,0;g041003.sql;!
27756; 5,3,93,0;g041003.sql;!
26263; 5,3,93,0;g041027.sql;!
26264; 5,3,93,0;g041027.sql;!
26265; 5,3,93,0;g041027.sql;!
26266; 5,3,93,0;g041027.sql;!
26267; 5,3,93,0;g041027.sql;!
26268; 5,3,93,0;g041027.sql;!
26269; 5,3,93,0;g041039.sql;!
26270; 5,3,93,0;g041039.sql;!
26291; 5,3,93,0;g041048.sql;!