Created
June 20, 2026 09:25
-
-
Save naranyala/b34ba5a1c2afab643b870b371f86e412 to your computer and use it in GitHub Desktop.
select-and-uninstall-snap-pkg.sh
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
| #!/usr/bin/env bash | |
| set -e | |
| ######################################## | |
| # Snap Uninstaller Selector | |
| ######################################## | |
| # Ensure snap is installed | |
| if ! command -v snap >/dev/null 2>&1; then | |
| echo "β Snap is not installed. Please install it first." | |
| exit 1 | |
| fi | |
| # Get list of installed Snap package names | |
| mapfile -t apps < <(snap list | awk 'NR>1 {print $1}') | |
| if [[ ${#apps[@]} -eq 0 ]]; then | |
| echo "β οΈ No Snap packages installed." | |
| exit 0 | |
| fi | |
| echo "π Installed Snap packages:" | |
| PS3="Enter the number of the Snap you want to uninstall: " | |
| select app_id in "${apps[@]}"; do | |
| if [[ -n "$app_id" ]]; then | |
| echo "β You selected: $app_id" | |
| read -rp "Are you sure you want to uninstall $app_id? [y/N]: " confirm | |
| if [[ "$confirm" =~ ^[Yy]$ ]]; then | |
| sudo snap remove "$app_id" | |
| echo "β $app_id has been uninstalled." | |
| else | |
| echo "π« Uninstall cancelled." | |
| fi | |
| break | |
| else | |
| echo "Invalid choice. Try again." | |
| fi | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment