10 command not found
Hello,
I am working on learning if-else statement, no matter what I do, it is throwing error. I am working on Ubuntu. #! /bin/bash count=10 if [$count -eq 10] then echo "condition is true" fi Kindly help |
ubuntu@ip-172-31-92-85:~/suman$ cat ifelse.sh
#! /bin/bash count=10 if [$count -eq 10] then echo "condition is true" fi ubuntu@ip-172-31-92-85:~/suman$ ./ifelse.sh ./ifelse.sh: line 3: [10: command not found ubuntu@ip-172-31-92-85:~/suman$ |
You need white space after the [, otherwise the shell thinks you want to run a program named [10. Also white space before the ].
|
Perfect, thank you, I have another question please, in the same lines as the operator. I see that the string equals the operator '='. What is assignment operator represented as?
|
you might want to use www.shellcheck.net to check your srcipt.
also please use [code]here comes your code[/code] tags to post scripts. That will make it more readable. |
Quote:
Code:
if ((count==11)) |
You should probably bookmark this https://www.tldp.org/LDP/abs/html/comparison-ops.html
|
Thank You Chris
|
All times are GMT -5. The time now is 12:25 PM. |