Malheureusement le nombre d’espace n’est pas constant
en fait j’ai fini par trouver, le soucis c’est qu’il y a des caractères de contrôle et des caractères accentué finlandais, danois, norvegien, allemand, etc…
#!/bin/bash
fic=$1
fout=$2
lasdtdir=""
count=0
nnewfile=`grep -E '^i\s*New\sFile' $fic | wc -l`
nnewdir=`grep -E '^i\s*New\sDir' $fic | wc -l`
nerrfile=`grep -E 'ERROR 112 \(0x00000070\) Copying File' $fic | wc -l`
echo "*****************************************************************************"
echo "* Date : $( date )"
echo "* File in : $fic"
echo "* File out : $fic2"
echo "* Number of New Dir detected : $nnewdir"
echo "* Number of New File detected: $nnewfile"
echo "* Number of File with error : $nerrfile"
echo "*****************************************************************************"
while read line
do
nname=""
size=""
fileis=""
pattern=""
# echo "$count : line=$line"
if [[ "$line" =~ EUOSMSFS011 ]]; then
lastdir=`echo $line | grep -Eo '\/\/EUOSMSFS011.*'`
# echo "lastdir=$lastdir"
fi
pattern="^i\s*New\sDir"
if [[ "$line" =~ $pattern ]]; then
echo "d;$count;$lastdir" > $fout
fi
pattern="^i\s*New\sFile"
if [[ "$line" =~ $pattern ]]; then
# echo "$count: Nouveau fichier"
size=`echo $line | sed -r 's/^i\s*New\sFile\s*([0-9]*\.*[0-9]{1}\s{0,1}[mg]{0,1}[^\s])\s+(.*)/\1/'`
nname=`echo $line | sed -r 's/^i\s*New\sFile\s*([0-9]*\.*[0-9]{1}\s{0,1}[mg]{0,1}[^\s])\s+(.*)/\2/'`
fileis=`echo $lastdir$nname`
# echo "$count : size=$size"
# echo "$count : nname=$nname"
# echo "$count : lastdir=$lastdir"
# echo "$count : fileis=$fileis"
echo "f;count;$fileis" > $fout
fi
# echo "$count : END : line=$line"
((count++))
echo "Line count : $count"
done < $fic