On Sun, Aug 7, 2011 at 8:16 PM, Dave Reisner <d@falconindy.com> wrote:
On Sun, Aug 07, 2011 at 05:14:06PM -0400, Eric Bélanger wrote:
pacsysclean sort installed packages by decreasing installed size. It's useful for finding large unused package when doing system clean-up. This script is an improved version of other similar scripts posted on the forums. Thanks goes to Dave as I reused the size_to_human function from his paccache script.
Signed-off-by: Eric Bélanger <snowmaniscool@gmail.com>
---
If you can think of a better name, feel free to suggest one.
I don't like the idea of using temp files for this when stdout will suffice (meaning the user can do with what they want. You can join all this together:
while read -r package; do printf '%s\t%s\n' "$(pacman -Qi $package | awk '/^Installed Size/{print $4}')" "$package" done | sort -gr | while IFS=$'\t' read -r size pkg; do printf '%s\t%s\n' "$pkg" "$(size_to_human "$size")" done
I only used temp files because I didn't know how to do the sorting and size conversion together. I'll replace that with your while loop.
But really, this is why I wrote expac.... so all that pacman|awk stuff turns into...
expac '%n\t%m' | sort -rgk2 | while IFS=$'\t' read name size; do printf '%s\t%s\n' "$name" "$(size_to_human "${size% *}")" done
Obviously, not officially sanctioned...
Any reason why you didn't submitted it as a pacman contrib? Otherwise, if I use it we'll need to add it as an optdepends for the pacman-contrib package. Eric
dave