I am making a script that you put two numbers and it tells you if they are divisible. But it gives me an error. I am making a script that you put two numbers and it tells you if they are divisible. But it gives me an error. THE SCRIPT CODE:
#!/bin/bash
read -p "Numero 1: " num1
read -p "Numero 2: " num2
cero=0
$op=$(($num1%$num2))
if [$op -eq $cero]
then
echo "ES DIVISIBLE"
else
echo "NO ES DIVISIBLE"
fi
/divisibles.sh
Numero 1: 4
Numero 2: 4
./divisibles.sh: línea 6: =0: orden no encontrada
./divisibles.sh: línea 7: [: falta un `]'
NO ES DIVISIBLE
op
when initializing it goes without the$
;
in the conditionalif
:Result:
It may be that your problem is that instead of declaring the variable, that is, creating it, you are calling it as if it already existed. The code should be something like this:
Tell me if it works for you because I haven't been able to test it