Skip to content

Instantly share code, notes, and snippets.

@lucascompython
Created June 5, 2022 21:03
Show Gist options
  • Save lucascompython/c49d0721bd5d3fb25ee4fe8e557ec294 to your computer and use it in GitHub Desktop.
Save lucascompython/c49d0721bd5d3fb25ee4fe8e557ec294 to your computer and use it in GitHub Desktop.
Shell script (basically just awk) to view a list of the packages that use more space in your disk, PACMAN ONLY.
#!/bin/sh
pacman -Qi | awk $@ '
BEGIN {
units["B"] = 0
units["KiB"] = 1
units["MiB"] = 2
units["GiB"] = 3
if (unit == "") unit = "MiB"
if (min == "") min = 50
if (pad == "") pad = 10
}
/^Name/ {name=$3}
/^Installed Size/ {
size = (int($4) * 1024^units[$5]) / 1024^units[unit]
if (size > min) printf "% *.1f %s %s\n", pad, size, unit, name
}
' | sort -n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment