I have a simple bash script as follows:
#!/bin/bash
n=$(( RANDOM % 100 ))
if [[ n -eq 42 ]]; then
echo "Something went wrong"
>&2 echo "The error was using magic numbers"
exit 1 fi
echo "Everything went according to plan"
However, when I run the code by typing into the bash the following:
sh script.sh
I got the following output:
script.sh: 5: [[: not found
Everything went according to plan
Why does it print script.sh: 5: [[: not found
? I know I have missed something on line 2 but I do not know what.