views:

283

answers:

1

Has anybody tried bash scripting on android? I tried to write a simple script on Android's bash shell through adb. I tried the following script which works for me:

#sh1
x="hello"
echo "$x"

But when I do:

#sh1
x="hello"
if [ -n "$X" ]; then
    echo "hi"
fi

The error says [ -n not found!

Why do I get this error and is there a work around?

A: 

Even though you show a space after the left square bracket in your question, you may not have one in your script. As a further diagnostic try a line with nothing but a left square bracket:

[

you should get an error message similar to:

-bash: [: missing `]'

If it still says "not found" then there's something else going on.

Dennis Williamson