I want to check if a directory exists on Android.
From an answer to Check if a file exists with a wildcard in a shell script, I get an idea. So I use ADB like below.
if [ adb shell ls ${test_dir}  2> /dev/null ] ;
then
   echo "files exist"
else
   echo "files do not exist"
fi
I am new to Bash scripting. I know adb shell ls will return all file names. But what's meaning of 2> /dev/null?
And I only care about files do not exist condition. So how do I  invert the condition?
Second version
if [ ! adb shell ls ${test_dir}  2> /dev/null ] ;
then
   echo "files exist"
else
   echo "files do not exist"
fi
Adding ! cannot work for me.
 
     
    