ESTRUCTURAS - mbelanabel/repositorio-scripts-alumnos GitHub Wiki
Estructuras de control
##CONDICIONALES##
- CONDICIÓN "if"
if condición
then
órdenes
[else
órdenes]
fi
if condición
then
órdenes
if condición 2
then
órdenes
....
IMPORTANTE !! cerrar cada IF
##SELECCIÓN##
Selección "CASE"
case variable in
opción1)
....
;;
opción2)
....
;;
*) // opcional
....
;;
esac
Selección "SELECT"
--- SE INCLUIRÁ EL PROMPT CON PS3="...."
OPCIONES="Si No"
select opt in $OPCIONES
do
if [[ $opt = "Si" ]]
then
....
elif [[ $opt = "No" ]] --- se podría analizar y sustituir por un <else> (la otra opción es "No")
then
....
fi
done
##BUCLES##
FOR, WHILE y UNTIL
*for** --- recoger valores de una lista ----
for variable [in lista]
do
órdenes
done
// exp1; exp2; exp3 (ini=0; ini<=10; ini++) --- contador --
for (( EXP1; EXP2; EXP3 ))
do
órdenes
done
**while**
while condición
do
órdenes
done
**until**
until condición
do
órdenes
done