Identify the error in the code
2 posters
Identify the error in the code
read $s
if [ $s -eq y ]
then
echo 'true'
else
echo 'false'
fi
----------------------
Error:
line 2: [: eq: unary operator expected
false
if [ $s -eq y ]
then
echo 'true'
else
echo 'false'
fi
----------------------
Error:
line 2: [: eq: unary operator expected
false
jennyinhere- Posts : 24
Points : 30
Join date : 2010-02-26
Age : 35
Re: Identify the error in the code
- Code:
read s
if [ $s ="y" ]
then
echo true
else
echo false
fi
"-eq" can be used only to compare numerical data not a string.
Similar topics
» header file is not getting recognised (in Eclipse/C++)
» error in while loop
» Command error
» error: return type for `main' changed to `int'
» please check sleep code.
» error in while loop
» Command error
» error: return type for `main' changed to `int'
» please check sleep code.
Permissions in this forum:
You cannot reply to topics in this forum
|
|