You are not logged in.
Pages: 1
Topic closed
Hello,
Here is how to list you installed packages by size (can be useful if you need space)
$ pacman -Qi | egrep '^(Name|Installed)' | cut -f2 -d':' | tr '\nK' ' \n' | sort -nrk 2 | less
Props to Abazigal from archfr
Idea from http://www.planet-libre.org/#post8360
Last edited by Kooothor (2011-01-19 23:05:21)
ktr
Offline
Oh, cool !
ktr
Offline
I usually look into the pacman cache folder. I know, DL size and installed size differ from package to package, but it's a rough approximation.
However, this is quite elegant, so thanks a lot.
Online
In gawk: (To the awk guru's out there, go gentle as I just start learning awk!)
Print low to high:
pacman -Qi | gawk '/^Name/ { x = $3 }; /^Installed Size/ { sub(/Installed Size *:/, ""); print x":" $0 }' | sort -k2,3n
Print high to low:
pacman -Qi | gawk '/^Name/ { x = $3 }; /^Installed Size/ { sub(/Installed Size *:/, ""); print x":" $0 }' | sort -k2,3nr
Print 10 largest programs: (high to low)
pacman -Qi | gawk '/^Name/ { x = $3 }; /^Installed Size/ { sub(/Installed Size *:/, ""); print x":" $0 }' | sort -k2,3rn | head -n10 | gawk 'BEGIN { print "\n""These are your 10 largest programs:""\n" }; { print }'
In sed: (I can't find this now to attribute the author but it used to be posted somewhere in the wiki)
alias package_size="LANG=C pacman -Qi | sed -n '/^Name[^:]*: \(.*\)/{s//\1 /;x};/^Installed[^:]*: \(.*\)/{s//\1/;H;x;s/\n//;p}' | sort -nk2"
As I said above, I'm learning awk so I thought this might be a good exercise!
In solving a problem of this sort, the grand thing is to be able to reason backward. That is a very useful accomplishment, and a very easy one, but people do not practice it much. In the everyday affairs of life it is more useful to reason forward, and so the other comes to be neglected. There are fifty who can reason synthetically for one who can reason analytically. --Sherlock Holmes
Offline
Another awk (show in Mbs) entry:
pacman -Qi | awk 'BEGIN{sort="sort -k2 -n"} /Name/ {name=$3} /Size/ {size=$4/1024;print name":",size,"Mb"|sort}'
Edit: size=0 was not needed.
Last edited by Ashren (2011-01-21 19:55:36)
Offline
Very cool, Ashren!
I knew all of it could probably be done in awk but I'm not quite there yet so thank you for the example!!
In solving a problem of this sort, the grand thing is to be able to reason backward. That is a very useful accomplishment, and a very easy one, but people do not practice it much. In the everyday affairs of life it is more useful to reason forward, and so the other comes to be neglected. There are fifty who can reason synthetically for one who can reason analytically. --Sherlock Holmes
Offline
You're welcome harryNID. Although, the pacman -Qi command still needs to be integrated. A challenge?
Offline
Offline
Offline
update expac.
OK, now it does work :-)
Offline
You're welcome harryNID. Although, the pacman -Qi command still needs to be integrated. A challenge?
All inclosed within an awk command (and with prettier printing):
awk 'BEGIN{while (("pacman -Qi" |getline) > 0){ if ($0 ~ /Name/) {name=$3};{if ($0 ~ /Size/) {size=$4/1024;print name": ",size,"Mb"|"sort -k2 -n|column -t"}}}}'
I tend to obsess about things like this - now I can get on with my day.
Using printf instead of column:
awk 'BEGIN{while (("pacman -Qi" |getline) > 0){ if ($0 ~ /Name/) {name=$3};{if ($0 ~ /Size/) {size=$4/1024;printf "%-25s %d Mb\n", name, size|"sort -k2 -n"}}}}'
Last edited by Ashren (2011-01-23 12:32:50)
Offline
Hello,
Here is how to list you installed packages by size (can be useful if you need space)
$ pacman -Qi | egrep '^(Name|Installed)' | cut -f2 -d':' | tr '\nK' ' \n' | sort -nrk 2 | less
Props to Abazigal from archfr
Idea from http://www.planet-libre.org/#post8360
Thanks for spreading the idea, I still find this useful. However, tr '\nK' ' \n' does not work for me. I have replaced it with paste - - :
$ pacman -Qi | egrep '^(Name|Installed)' | cut -f2 -d':' | paste - - | column -t | sort -nrk 2 | grep MiB | less
also inspired from commandlinefu
Offline
I think it's about time to put this thread to rest.
Closing.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
Pages: 1
Topic closed