"adb pull" 抛出 "does not exist"

"adb pull" throws "does not exist"

当我执行命令时:
for el in $(adb shell ls /mnt/sdcard/ | grep mem_); do adb pull /mnt/sdcard/${el} android_mem; done
我得到:
' 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 ...
但是,如果我执行此操作,例如 adb pull /mnt/sdcard/mem_DCIM android_mem,我会得到 0 KB/s (20 bytes in 0.080s),即可以。为什么会这样??

问题是 adb shell ls /mnt/sdcard/ | grep mem_ 在末尾返回一个 \r,因此无法正确提取文件。

所以需要用sed -r 's/[\r]+//g'去掉,例如:

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