[ is a command builtin, also known as
test, and as all commands requires at least a space to separate it from other words in the command.
[ is also available as a regular command in
The presence of a final
] is instead a requirement of the command, when invoked as
[, and the spaces around it are required as for every parameter of a command.
That said, in bash you should use the command
[[, that has some avantages over
[, like for example supporting
|| for logical operations, beside
Moreover, to do integer arithmetic operations and comparison between integers it is better to use arithmetic expansions
$((math operations)), and the corresponding command
With these observations, your script could be:
echo "Enter 1st number"
echo "Enter 2nd number"
echo "Multi is $((n1 * n2))"
if ((n1 > n2)); then
echo "$n1 is bigger than $n2"
echo "$n2 is bigger than $n1"
Remember to make it executable (
chmod +x my-script), then execute it with