I'm making a simple application that is passed a string and returns the first character, I used a loop so if I wanted to ask multiple times I wouldn't have to open and open the file.
#! /bin/bash
while true
do
echo -n "Digite el la cadena de la cual desea saber el primer digito: ";
read numero;
echo "El primer caracter es: '${numero:0:1}'";
echo "Si desea intentar de nuevo presione 1, de lo contrario presione 2:";
read salir;
if $salir != $1; then
echo "Adios :)";
$DELAY;
break
fi
done
The strange thing is that it tells me that in line 14 (which is done ) it does not find what we typed to continue or exit:
So it generates an infinite loop. 1) I don't know how to get out of the infinite loop, 2) I don't know what the done has to do with it, and 3) I don't know how to make it work correctly. I appreciate your time and help in advance.
Your code is poorly written, maybe you copied and pasted it wrong and you are missing quotes, besides that you are using the comparison operator wrongly and you are not assigning any value or use to the variable
DELAY
, besides that in your code you make use of the character;
which is not necessary if you have line breaks.Your code should be something like this.
It's just that the variable
DELAY
isn't used for anything.