I want to test if two variables exist, after i used “read” to create it. If the user enter just one of two variables i want, it display an error.
There is my code :
while true;
do
echo "Saisissez deux variables x et y sous la forme [x y]"
read x y
if [ !-e $x ] || [ !-e $y ] <<<<<< problem ligne
then
echo "Vous devez renseigner deux nombres x et y"
elif [ $x = "." ]
then
exit 0
else
calcul $x $y
fi
done
and there is the error when i just enter an argument :
[: !-e: unary operator expected
Thanks for your help 🙂
Change it to:
Explanation
[is actually a shell built-in (trywhich [orhelp [on your prompt); it’s is a synonym fortest.-zis an argument to[. it means “test if the length of the next string is 0; return true if so; return false otherwise.Here’s a list of useful options to
[since I think you’d be interested: