Last active
April 17, 2018 20:09
-
-
Save zvyn/5694729 to your computer and use it in GitHub Desktop.
My disk went full so I wrote the following script to generate a list of all installed packages with their (theoretical) disk-usage as estimated by pacman.
#ArchLinux #pacman
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/bash | |
function list-package-sizes () { | |
if [ $1 ]; then | |
case $1 in | |
-h|--help) | |
local errno=0 | |
;; | |
*) | |
local errno=1 | |
echo Error: I do not accept any parameters else then \'-h\' or \'--help\'. | |
;; | |
esac | |
echo Returns a sortet list of package-sizes in KiB \(and names\) for all packages installed via pacman. | |
return $errno | |
else | |
pacman -Qq |\ | |
pacman -Qi |\ | |
egrep "(Name +:|Installed Size :)" |\ | |
tr -d "\n" |\ | |
sed -E "s/(Installed Size :|Name +| KiB)//g" |\ | |
sed -E "s/ +/ /g" |\ | |
tr ":" "\n" |\ | |
awk '{print $2,$1}' |\ | |
sort -n | |
return $? | |
fi | |
} | |
if [[ $0 == *list-package-sizes.bash ]]; then | |
list-package-sizes "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I noticed a couple of bugs with the text processing.