
Numero, mas alto, mas, bajo y medio
Publicado por Tomas (13 intervenciones) el 20/03/2014 10:11:02
Tengo que hacer que me diga el numero mas alto, mas bajo y medio, lo he intentado pero solo me sale el mas alto.
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
30
31
32
33
34
35
36
#!/bin/bash
fichero=$1
if [ -f $1 ];then
max=0
min=200
while read line ; do
echo $line
if [ $line -gt $max ]; then
max=$line;
elif [ $line -lt $min ]; then
min=$line
fi
if [ $line -lt $max && $line -gt $min ];then
media=$line
fi
if [ $line -gt 200 ] ;then echo $line >> mayores.txt
elif [ $line -lt 200 ] ;then echo $line >> menores.txt
fi
if [ $line -eq 200 ] ;then echo $line >> mayores.txt
fi
done <$fichero
else
echo No has introducido un directorio o un fichero valido.
fi
echo El mas alto mide $max
echo El mas bajo mide $mix
echo El mediano mide $media
Valora esta pregunta


0