ceu-notes/1/ISO/examenes/tema11-naortega/ej1.sh

28 lines
285 B
Bash
Raw Permalink Normal View History

2022-04-29 17:49:41 +00:00
#!/bin/bash
if [ $# -lt 3 ]
then
echo "Son necesarias al menos 3 argumentos numéricos."
exit 1
fi
# a
echo "Se han introducido $# argumentos."
# b
SUM=0
for i in ${@:1:3}
do
SUM=$[$SUM+$i]
done
AVG=$(echo "scale=3; $SUM / 3" | bc)
echo $AVG
# c
echo $@
# d
echo $[$2 ** $3]