Reputation: 3221
Hello im new to bash scripting, i have a simple program which is not working for me. I assume its a syntactical error.
#!/bin/bash
#example1.sh
read Age
if ["$Age" -lt "18"]; then
echo "You must go to school"
fi
When i input a 1 it says [1: command not found
Upvotes: 0
Views: 129
Reputation: 218
#!/bin/bash
#example1.bash
read Age
if(($Age < 18)); then
echo "You must go to school"
fi
This code works when it is run in bash. Bash and sh are not completely the same.
Upvotes: 0
Reputation: 272447
You need spaces:
if [ "$Age" -lt "18" ]; then
(Summary: Bash syntax rules are appalling.)
Upvotes: 6