[Linux-Biella] Script

CIARROCCHI, Paolo, VF-IT linux@ml.bilug.linux.it
Wed, 21 Jan 2004 09:41:54 +0100


From: Claudio M. [mailto:cmaffio@bilug.linux.it] 
> On Tue, 20 Jan 2004 18:15:25 +0100
> "CIARROCCHI, Paolo, VF-IT" <Paolo.CIARROCCHI@vodafone.com> wrote:
> 
> > che pero' mi da un bel...
> > 
> > ./SDstats.sh: counter++: command not found
> 
> bhe, forse perche la shell non e' C-like!!!!

Si ma avevo fatto un bel man bash...
 
> Scusa, ma fare un bel 
> flag=1
> for <tutto quello che deve fare>
> <istr1>
> <istr2>
> <istr3>
> if ($flag eq 1) {
> 	<quello che devi fare>
> 	flag = 0
> }
> fine for

E' la prima cosa che ho provato, ma non sono
riuscito a far funzionare l'if allora l'ho abbandonato...

Questo ora funziona:

#!/usr/bin/bash
lista=$(ls SDST*.TXT)
counter=1;
for i in $lista;
do
born=$(./erasefirstline.sh $i|cut -d ";" -f 2)
killed=$(./erasefirstline.sh $i|cut -d ";" -f 3)
dead=$(./erasefirstline.sh $i|cut -d ";" -f 4)
date=$(echo $i|cut -d "_" -f 2|cut -d "." -f 1)
while [ $counter -le 1 ] ;
do
        /usr/bin/echo "Data \t\tBorn \tKilled \tDead"
	  counter=$(($counter+1))
done;

/usr/bin/echo "$date \t$born \t$killed \t$dead"
echo
done;

E' ora che torni a guardare come si programma in bash...


Grazie a tutti.

				Paolo