Search code examples
androidadb

"adb pull" throws "does not exist"


When I perform command:
for el in $(adb shell ls /mnt/sdcard/ | grep mem_); do adb pull /mnt/sdcard/${el} android_mem; done
I get:
' does not existmnt/sdcard/mem_AI ' does not existmnt/sdcard/mem_Alarms ' does not existmnt/sdcard/mem_Android ' does not existmnt/sdcard/mem_Autodesk ' does not existmnt/sdcard/mem_Cardboard ' does not existmnt/sdcard/mem_DCIM ...
But if I perform this, for example, adb pull /mnt/sdcard/mem_DCIM android_mem I get that 0 KB/s (20 bytes in 0.080s), ie ok. Why is this happens??


Solution

  • The problem is that adb shell ls /mnt/sdcard/ | grep mem_ is returning a \r at the end, so it can't pull the file properly.

    So you need to remove it with sed -r 's/[\r]+//g', for example:

    for el in $(adb shell ls /mnt/sdcard/ | grep mem_ | sed -r 's/[\r]+//g'); do adb pull /mnt/sdcard/${el} android_mem; done