I'm trying to use $EXTERNAL_STORAGE in the
adb pull command. I noticed that the variable has its scope defined in Android only and so it would not work successfully in
adb pull $EXTERNAL_STORAGE/Pictures/Screenshots/ ~/.
Of course, I can write an absolute path to fetch all the screenshots but the issue is something else.
af=$(adb shell echo \$EXTERNAL_STORAGE/Pictures/Screenshots/) adb pull $af ~/
which gives me the error:
' does not existstorage/sdcard0/Pictures/Screenshots/
Alternatively, if I do:
af="/storage/sdcard0/Pictures/Screenshots/" adb shell $af ~/
then the screenshots gets fetched successfully.
There is a difference in character count. For the first case where $af receives input from
adb shell, the output of
echo $af | wc -c is 39 and 40 respectively.
For the second case where a direct string is fed into $af, the output of
echo $af | wc -c is 38 and 39 respectively.
I thought this may be a result of trailing space, so I added a space in the
$af=/storage/sdcard0/Pictures/Screenshots/ " but
adb pull $af ~/ still worked well.
Also, I ran
echo $af | fold -w1 | wc -l and for both the cases the output is 38.
So, what's causing ADB to throw that error?
If it matters, I'm using Slackware 14.1 and rooted Android 4.2.1 and 5.0.2.