Villes intelligentes : Opportunités de croissance pour la France en Chine
Solution Problème Linux
1. Problème ( Solution )
Q1 )
#!/bin/bash
if [ $# -ne 5 ]
then
echo "Donnez les informations completes"
exit 1
fi
cat < Etudiants.txt | while true
do
read ligne
if [ "$ligne" = "" ]
then
exit 0
fi
mail=`echo $ligne | cut -d ":" -f 3`
if [ "$3" = "$mail" ]
then
echo "L'etudiant existe deja"
`touch temp`
exit 0
fi
done
if [ ! -e temp ]
then
echo "$1:$2:$3:$4:$5" >> Etudiants.txt
echo "L'etudiant a ete ajoute"
exit 2
fi
`rm temp`
2. Q2 )
#!/bin/bash
cat < Etudiants.txt | while true
do
read ligne
if [ "$ligne" = "" ]
then
exit 0
fi
n=`echo $ligne | cut -d ":" -f 4`
echo $ligne >> Etudiant$n.txt
done
Q3)
#!/bin/bash
echo "donner l'annee d'etude"
read annee
k=1
cat < Etudiant$annee.txt | while true
do
read ligne
if [ "$ligne" = "" ]
then
exit 0
fi
moy=`echo $ligne | cut -d ":" -f 5`
if [ $k -eq 1 ]
then
3. max=$moy
nom=`echo $ligne | cut -d ":" -f 1 `
prenom=`echo $ligne | cut -d ":" -f 2 `
echo "$nom $prenom $max" > major
k=5
fi
if [ $moy -gt $max ]
then
max=$moy
nom=`echo $ligne | cut -d ":" -f 1 `
prenom=`echo $ligne | cut -d ":" -f 2 `
echo "$nom $prenom $max" > major
fi
done
Q4)
#!/bin/bash
cat < Etudiants.txt | while true
do
read ligne
if [ "$ligne" = "" ]
then
exit 0
fi
prenom=`echo $ligne | cut -d ":" -f 1 `
nom=`echo $ligne | cut -d ":" -f 2`
email=`echo $ligne | cut -d ":" -f 3`
moy=`echo $ligne | cut -d ":" -f 5`
sujet="Moyenne generale"
message=" Bonjour M.$prenom $nom votre moyenne generale est $moy"
mail -s $sujet $message $email
done