I am getting this error while comparing shell argument to a string. If the code look like this:
online=true
if [ "$2" -eq '-o' ]
then
online=false
fi
echo $online
Then for e.g. input I am getting those results:
$ ./currency.sh 2 -o
./currency.sh: line 13: [: -o: integer expression expected
true
-eq
is an arithmetic test operator - for string comparison, use=
– steeldriver Mar 21 '18 at 01:56