I made a simple script, just to test if the user passed more than 2 arguments.
My script is the following
#!/bin/sh
if (( $# > 2 )); then
echo "greater"
else
echo "not greater"
fi
It should be really simple, since $#
returns the number of arguments, but I receive the following error:
schwarz@peano:~$ ./test.sh
./test.sh: 3: 0: not found
not greater
schwarz@peano:~$ ./test.sh one
./test.sh: 3: 1: not found
not greater
schwarz@peano:~$ ./test.sh one two
./test.sh: 3: 2: not found
not greater
schwarz@peano:~$ ./test.sh one two three
./test.sh: 3: 3: not found
not greater
schwarz@peano:~$ ./test.sh one two three four
./test.sh: 3: 4: not found
not greater
It says "not found" to the number of arguments I pass. What I'm doing wrong?
Thanks in advance.