I was reading a post and saw this syntax: (By the way, that unixness is fun)


$[T1 + T2]

Where T1 and T2 represent integer numbers. It is clear to me that it is equivalent to arithmetic expansion as $(( )) that I know. I actually I recall I have seen this square brackets format before, but I must not know much about Bash at that time, I didn’t pay much attention to it.

I consulted with manpage of Bash-4.1 and found no indications of it. I searched for \[ and the word arithmetic, none of those matches have mentioned this format of arithmetic expansion. Needless to say, I googled “bash $[“, but you know search engine can’t match symbols. (If you know any search engine can match symbols and punctuations, I would like to know the one is better than Google) I also tried the verbatim, still don’t do symbols. It is only for natural language, not programming language, I think.

So I searched for “bash arithmetic expansion”, the answers are actually in first page. This StackOverflow question has the answer. Apparently, the syntax is deprecated and it was mentioned in manpage of version 3.2.48, the version was released around at 17-Mar-2009 12:31. I guess it’s history, so they removed it from manpage but still keep the syntax.