📓 clearing-up-drive-space-used-by-snap.md by @neil ☆

Clearing up drive space used by snap

#!/bin/bash

# Check if a target snap is provided
if [ -z "$1" ]; then
    echo "Usage: $0 <target-snap>"
    exit 1
fi

TARGET_SNAP="$1"

# Get list of all installed snaps
INSTALLED_SNAPS=$(snap list | awk 'NR>1 {print $1}')

# Check connections and base for each snap
echo "Checking dependencies for: $TARGET_SNAP"
echo "----"

for snap in $INSTALLED_SNAPS; do
    # Check connections
    if snap connections "$snap" | grep -q "$TARGET_SNAP"; then
	echo "[Connection] $snap depends on $TARGET_SNAP"
    fi

    # Check base declaration
    if snap list "$snap" | awk -v target="$TARGET_SNAP" 'NR>1 {if ($5 == target) print}' | grep -q .; then
	echo "[Base Snap]   $snap uses $TARGET_SNAP as its base"
    fi
done