What’s wrong I get an error : ./greater[4]: [: argument expected
#!/bin/ksh
echo "please enter a nuber "
read $num
if [$num -ls 20 ]; then
echo "your nuber is greater than 20 "
else
echo "your number is less then 20 "
fi
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That above will read input into a variable which name is stored in
$num, which “obviously” isn’t correct. Change it toread numand it will work as expected.With the above change you’ll also need to add a space after
[on the line quoted below:Otherwise the command will look like the below code-snippet if the user enters 123, and your shell will complain about the command
[123isn’t found, or similar.