Look at your errors:
bash-3.2$ ./isingelogd
./isingelogd
./isingelogd: line 3: if[0=0]: command not found
./isingelogd: line 4: syntax error near unexpected tokenthen'
then'
./isingelogd: line 4:
See that command not found? you have an error in your script.
The [
..]
are actual commands, and like all commands, they need to be separated by white spaces. The =
is a parameter to the [
command and also needs to be surrounded by white space. Change line #3 to this:
if [ $# -eq 0 ]
Since $#
and 0
are numeric, you should use -eq
which compares to numbers and not =
which compares strings.
Try these commands:
$ ls -li /bin/test
$ ls -li /bin/[
You'll see they have the same inode number. They're links. (Yes, the [
and test
are builtins into the shell, but they are linked builtin commands).
$ man test
will give you all of the various tests that [
can do. Again, note the difference between -eq
vs. =
and -gt
vs. >
.
Note the following:
if [ 54 > 123 ]
then
echo "54 is greater than 123"
fi
This will print out "54 is greater than 123". This won't:
if [ 54 -gt 123 ]
then
echo "54 is greater than 123"
fi