-
-
Save 0xack13/a48a2138d8f4709293e43d67d0a0adf9 to your computer and use it in GitHub Desktop.
apk: list installed packages sorted by file size (e.g. alpine linux)
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
| #!/bin/ash | |
| # list installed packages sorted by file size | |
| apk info -e -s \* >/tmp/apksize | |
| awk 'NR % 3 == 1' /tmp/apksize | cut -d ' ' -f 1 > /tmp/apkname | |
| awk 'NR % 3 == 2' /tmp/apksize > /tmp/apksize2 | |
| while read -r n unit; do | |
| B=$n | |
| case "$unit" in | |
| KiB) B=$(( n * 1024 )) ;; | |
| MiB) B=$(( n * 1024 * 1024 )) ;; | |
| GiB) B=$(( n * 1024 * 1024 * 1024 )) ;; | |
| esac | |
| printf "%12u %4s %-3s\n" $B $n $unit | |
| done < /tmp/apksize2 > /tmp/apksize | |
| paste -d' ' /tmp/apksize /tmp/apkname | sort -n -u | cut -c14- | |
| rm /tmp/apksize /tmp/apksize2 /tmp/apkname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment