I am new to bash scripting and I have encountered a problem that I quite don't understand how to slove it. These are my codes:
n=$1
e=$2
echo "$n"
if [$e -eq 1]
then
echo "$n done"
echo "$e"
else
echo "$n done only"
fi
If I run the script as
./programName hello 1
The problem occurs as
./programName: line 6: [1: command not found
Only the else part runs after the first echo has been executed. I have tried starting the script in these ways:
./programName hello 1
./programName hello -e 1
./programName -n hello -e 1
While the first and second gives the same error as above. The third doesn't execute the first echo and gives the echo of the else part as -e done only