I'm studying basic Bash scripting on a Debian System 8.6. I've read an example I found on a book that shows how to build a conditional construct. I let you it below:
#!/bin/bash #Filname: CondConst.sh if [$UID -ne 0]; then echo "Non root User." else echo "Root User." fi
When I run the script containing this code I get the following error message and result:
[1000: command not found Root User.
I've tried to modify the code in many ways (using quotes and spaces), but I could not understand how to use square brackets syntax for the comparision. I worked out the issue by using a different syntax, that I show you below:
#!/bin/bash #Filname: CondConst.sh if (($UID!=0)); then echo "Non root User." else echo "Root User." fi
Can anyone explain me, if possible, the reason why I can not use square brackets?
Thank you, really, in advance.