#!/bin/bash
devicesName=$1
usesu=$2
pid=""
if [[ $usesu = "" ]];
then
adb shell "ls -l /mnt/sdcard/ucloud/dump*"
adb shell "ls -l /mnt/sdcard/ucloud/dump*" > dumpfiles.txt
else
adb shell su -c "ls -l /mnt/sdcard/ucloud/dump*"
adb shell su -c "ls -l /mnt/sdcard/ucloud/dump*" > dumpfiles.txt
fi
#Mi pad output with \r need to be dos2unix
dos2unix dumpfiles.txt
awk '{print $7}' dumpfiles.txt > dumpfiles2.txt
read -p "choose which to pull:" val
if [[ $val = "a" ]];
then
cat dumpfiles2.txt | while read myline
do
echo "pull /mnt/sdcard/ucloud/$myline"
adb pull /mnt/sdcard/ucloud/$myline ~/Templates/
#if echo "$myline" >/dev/null ;then
# echo "pull /mnt/sdcard/ucloud/$myline"
# adb pull "/mnt/sdcard/ucloud/$myline" ~/Templates/
#fi
done
else
adb pull "/mnt/sdcard/ucloud/$val" ~/Templates/
fi