2

I want to check if a certain directory (e.g. /data/textdata/) exists on the AVD using adb shell.

I'm following prolink007's answer on SO, except this line:

DIR_RESULT=$(adb shell ls /data/ | tr -d '\015'|grep '^textdata$')

but it goes always into the then branch if the directory exist or not. I've also looked for the adb shell manual without results.

Any suggestion?

1

I tried this on an avd and it works for me:

ls /data/textdata > /dev/null 2>&1 && echo "exists" || echo "not exists"
| improve this answer | |
0

Please try this:

DIR_RESULT=$(adb shell if [ -d  "/data/textdata" ]; then echo "exists"; else echo "not exists"; fi; );
| improve this answer | |
  • does not work. it says "exist.sh: command substitution: line 4: syntax error near unexpected token then' exist.sh: command substitution: line 4: then echo "exists"; else echo "not exists"; fi; '". I think is how the command is structured: if statement should not be there (in my opinion) – idell Dec 5 '13 at 15:13
  • the command of prolink007 now works: i was wrong in the command copy. – idell Dec 5 '13 at 15:26
  • I found a solution which works for me. See my second answer. – floriangosse Dec 5 '13 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy