Check if a certain directory exists on AVD using ADB command 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?
I tried this on an avd and it works for me:

ls /data/textdata &gt; /dev/null 2&gt;&amp;1 &amp;&amp; echo "exists" || echo "not exists"