shell-script-pt
[Top][All Lists]

## Res: Calculo em Centesimos

 From: William Alves dos Santos Subject: Res: Calculo em Centesimos Date: Thu, 8 Dec 2011 17:10:10 -0200

```Caros,

Ficou dessa forma, desprezei os centesimos para simplicar as coisas, e o
tratamento realmente será necessário para descobrir tempos superiores a 1
segundo.

Arquivo

14:54:30 14:54:31
14:54:32 14:54:33
14:54:54 14:54:55
14:55:7 14:55:8
14:55:38 14:55:39
14:55:53 14:55:54
14:56:28 14:56:31
14:56:30 14:56:33
14:56:34 14:56:35
14:57:20 14:57:21

cat log.tmp | tr ':' ' ' | while read LIN; do
hi=`echo \$LIN | awk '{print \$1}'`
mi=`echo \$LIN | awk '{print \$2}'`
si=`echo \$LIN | awk '{print \$3}'`
hsi=`expr \${hi} \* 3600`
msi=`expr \${mi} \* 60`
ssi=`echo \$si`
ini=`echo \$hsi \$msi \$ssi | tr ' ' '+' | bc`
hf=`echo \$LIN | awk '{print \$4}'`
mf=`echo \$LIN | awk '{print \$5}'`
sf=`echo \$LIN | awk '{print \$6}'`
hsf=`expr \${hf} \* 3600`
msf=`expr \${mf} \* 60`
ssf=`echo \$sf`
fim=`echo \$hsf \$msf \$ssf | tr ' ' '+' | bc`
echo \$fim \$ini | tr ' ' '-' | bc
done

Abraços

*William Alves dos Santos*
**Cel.: +55 (11) 6835 8172