Skip to content

Instantly share code, notes, and snippets.

@joaomagfreitas
Created February 22, 2025 18:22
Show Gist options
  • Select an option

  • Save joaomagfreitas/bbb76d739f657e2653819e321b9c0279 to your computer and use it in GitHub Desktop.

Select an option

Save joaomagfreitas/bbb76d739f657e2653819e321b9c0279 to your computer and use it in GitHub Desktop.
adb-uninstall-apps
#!/usr/bin/env bash
# Ensure ADB is connected
echo "Checking ADB connection..."
adb devices | grep "device$" > /dev/null
if [ $? -ne 0 ]; then
echo "No device found. Ensure USB debugging is enabled and try again."
exit 1
fi
# Get the list of third-party packages
packages=$(adb shell pm list packages -3 | sed 's/package://')
if [ -z "$packages" ]; then
echo "No third-party packages found."
exit 0
fi
echo "Found the following third-party packages:"
echo "$packages"
echo "Starting removal process..."
for package in $packages; do
read -p "Do you want to remove $package? (y/N): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
adb uninstall "$package"
if [ $? -eq 0 ]; then
echo "$package removed successfully."
else
echo "Failed to remove $package."
fi
else
echo "Skipped $package."
fi
done
echo "Process complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment