-3

Possible Duplicate:
shell script in android gives [: not found

i need to write one conditional statement in shell script.

i have used this way

#!/bin/sh
c=1
if [ $c == 1 ]
then
  echo c is 1
else
  echo c is 0
fi

this works fine in linux machine but android shell has some problem with if [ $C == 1 ] it gives me error like

[: not found

so is there any other condition statement in shell script so i can convert my logic at that way?

Community
  • 1
  • 1
Jeegar Patel
  • 26,264
  • 51
  • 149
  • 222
  • 3
    You've already asked the [same question](http://stackoverflow.com/questions/12056625/shell-script-in-android-gives-not-found). Please edit or comment on the original question. – pb2q Aug 22 '12 at 04:31

1 Answers1

1

generally [ is an alias for test, in bash it's a built-in. type [ to see what it's.

Another option is to use test

#!/bin/sh
c=1
if test "$c" = 1
then
  echo c is 1
else
  echo c is 0
fi

= for string comparison, -eq for numeric comparison

Nahuel Fouilleul
  • 18,726
  • 2
  • 31
  • 36