Last active
February 18, 2018 16:06
-
-
Save ashdavies/7812583e6bc817effdebc2e4af64b8d2 to your computer and use it in GitHub Desktop.
Save matching APK files from an Android device
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if test $# -lt 1; then | |
echo "usage: apk pattern target_directory" | |
exit 1 | |
fi | |
DIR="${2:-$PWD}" | |
for ENTRY in $(adb shell pm list packages -f | grep $1); do | |
PACKAGE=$(echo $ENTRY | sed -n 's/package:\(.*\)=.*$/\1/p') | |
NAME=$(echo $ENTRY | sed -n 's/^.*apk=\(.*\).*$/\1/p') | |
echo "Saving $PACKAGE to output directory $DIR/$NAME.apk" | |
adb pull $PACKAGE $DIR/$NAME.apk | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment