shell script in android gives [: not found

前端 未结 8 1334
一个人的身影
一个人的身影 2021-01-20 23:31

I have this script which works on my linux machine

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

But when I use this in

8条回答
  •  悲&欢浪女
    2021-01-21 00:16

    Use bash:

    #!/system/bin/bash

    or

    #!/system/xbin/bash

    You can check where your sh binary is pointing to on your Linux machine:

    ls -l /bin/sh
    

    Edit

    BTW, use:

    c=1
    if [ $c -eq 1 ]
    then
      echo c is 1
    else
      echo c is 0
    fi
    

提交回复
热议问题