1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #!/bin/bash
tableau=( $(date +'%-A %-H %-M') )
minute=${tableau[2]}
if [ ${tableau[0]} = "samedi" ]
then
horaire=/home/raphael/Documents/Programmation/Shell/horaires_samedi
elif [ ${tableau[0]} = "dimanche" ]
then
horaire=/home/raphael/Documents/Programmation/Shell/horaires_dimanche
else horaire=/home/raphael/Documents/Programmation/Shell/horaires_semaine
fi
horairesmodif=`grep ^${tableau[1]} $horaire | sed -e 's/\([0-9][0-9]\)h\([0-9][0-9]\)/\2/' | sed -e 's/^0//'`
for min in $horairesmodif
do
if [ $min -gt $minute ]
then
let "c = min - minute"
echo "Bus dans $c minutes"
fi
done
let heure_m=${tableau[1]}+1
horairesmodif2=`grep ^$heure_m $horaire | sed -e 's/\([0-9][0-9]\)h\([0-9][0-9]\)/\2/' | sed -e 's/^0//'`
for min in $horairesmodif2
do
let d=60-${tableau[2]}
let e=d+min
echo "Bus dans $e minutes"
done
echo "Valable jusqu'au 7 juillet 2013" |