Bash: (foo==0)?foo=1:foo=0 valid?

inode0 inode0 at gmail.com
Sat Jul 2 18:09:18 UTC 2011


On Sat, Jul 2, 2011 at 12:45 PM, Daniel B. Thurman <dant at cdkkt.com> wrote:
>
> I seem to forget my shell programming
> but is the following statement valid?
>
> ($foo==0)?foo=1:foo=0
>
> I thought it was called the tristate conditional
> operator but in any case I could not find it in
> google.

I think you might be looking for something similar to

foo=$(($foo==0 ? 1 : 0))

John


More information about the users mailing list