I used the $(()) command and I seen this error:

bash: 0: command not found

Why did this error occur?

1 Answer 1


The $(( )) is an arithmetic substitution or arithmetic expansion. Within it, you may do (integer) arithmetic operations, and the shell would carry them out and replace the whole expression with the result of those operations.

You often see it used like in

count=$(( count + 1 ))

Since there is nothing for the shell to do here (the arithmetic substitution is empty), your bash shell decides that the result is zero.

You are using this as a command, which means the shell would try to run the result, 0, as a command.

It fails, and tells you why ("0: command not found").

This, an empty arithmetic substitution, seems to be a corner case that is treated differently in different shells. The bash shell, along with zsh and pdksh (ksh on OpenBSD) tries to execute 0, while dash and yash complains:

$ dash -c '$(( ))'
dash: 1: arithmetic expression: expecting primary: " "
$ yash -c '$(( ))'
yash: arithmetic: a value is missing

The POSIX standard says

As an extension, the shell may recognize arithmetic expressions beyond those listed.

... which may be what bash, zsh and pdksh does (i.e., they recognize an empty expression as "zero").


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .