Skip to content

Instantly share code, notes, and snippets.

@mcrisc
Created May 9, 2018 13:49
Show Gist options
  • Save mcrisc/9761db53fe5368b03a157b2ceb794f9f to your computer and use it in GitHub Desktop.
Save mcrisc/9761db53fe5368b03a157b2ceb794f9f to your computer and use it in GitHub Desktop.
Uninstall Android applications via ADB
#!/bin/bash
ADB="$ANDROID_HOME/platform-tools/adb"
if [ -z "$1" ]; then
echo "usage: $0 <filter> [rm]"
exit 1
fi
FILTER="$1"
CMD="$2"
for app in `$ADB shell pm list packages $FILTER | sed -e 's/package://' | tr -d '[\r\n]'`;
do
if [ "$CMD" == "rm" ]; then
CMDLINE="${ADB} shell pm uninstall ${app}"
echo $CMDLINE
eval $CMDLINE
else
echo "$app"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment