I'm making an script that gives me a day like this jjj/yyyy when I give it a day like this dd/mm/yyyy and I need it to have an error when you don't write correctly but I'm starting and it's not working :(
#! /bin/bash
#Primero debes ingresar el mes
echo "Ingresa el número de un mes del año"
read mes
#Condicional
#Dependiendo si coloca bien $mes
if [ "$mes" -lt 12 -a "$mes" -gt 0 ]; then
echo "muy bien, sigamos."
else
if [ "$mes" -gt 12 -a "$mes" -lt 0 ]; then
echo "Creo que eso ya no es un mes!";
exit
fi
When I run it it says "syntax error near unexpected end of file"
-lt
and-gt
are for strictly greater. -lt 12 and -gt 0 means from 1 to 11. Use-le
for less than or equal.