Unary operators is an "instruction" composed of two symbols, which need not necessarily be between two terms (variables, etc.).
When referring to the unary operator, the interpreter refers to its ==
comparison sequence that is being used in the wrong way.
In the case of your code, the error is given because of the way the operator is used. The ==
operator compares two Strings into ShellScript .
#!/bin/bash
echo "Digite 1:"
read TESTE # Não existe cifrão na atribuição do valor em uma variável
if [ "$TESTE" == "654" ]; then
echo "Usage: ./pingscript.sh [network]"
echo "example: ./pingscript.sh 192.168.20"
fi
In case of comparison of numeric values, or existence of files, etc. Specific SH operators are used for this.
-
-eq (Equality)
-
-le (Minor or Equal)
-
-lt (Less Than)
-
-ge (Greater than or equal to)
-
-gt (Higher than)
#!/bin/bash
echo "Digite 1:"
read TESTE
if [ $TESTE -eq 654 ]
then
echo "Usage: ./pingscript.sh [network]"
echo "example: ./pingscript.sh 192.168.20"
fi