You are not logged in.

#1 2011-01-19 23:04:35

Kooothor
Member
From: Paname
Registered: 2008-08-02
Posts: 226

List all installed packages by size

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

big_smile

Last edited by Kooothor (2011-01-19 23:05:21)


ktr

Offline

#2 2011-01-19 23:37:59

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: List all installed packages by size

If you have expac you can

expac "%n %m" -l'\n' -Q $(pacman -Qq) | sort -rhk 2 | less

And there's Allan's bigpkg

Edit: typo.

Last edited by karol (2011-01-22 02:08:12)

Offline

#3 2011-01-21 17:39:53

Kooothor
Member
From: Paname
Registered: 2008-08-02
Posts: 226

Re: List all installed packages by size

Oh, cool ! smile


ktr

Offline

#4 2011-01-21 18:43:11

Awebb
Member
Registered: 2010-05-06
Posts: 6,286

Re: List all installed packages by size

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.

Offline

#5 2011-01-21 19:32:28

harryNID
Member
From: P3X-1971
Registered: 2009-06-12
Posts: 117

Re: List all installed packages by size

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!  smile


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

#6 2011-01-21 19:48:52

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: List all installed packages by size

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

#7 2011-01-21 19:58:58

harryNID
Member
From: P3X-1971
Registered: 2009-06-12
Posts: 117

Re: List all installed packages by size

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!! smile


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

#8 2011-01-21 20:13:42

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: List all installed packages by size

You're welcome harryNID. Although, the pacman -Qi command still needs to be integrated. A challenge?

Offline

#9 2011-01-22 01:05:37

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: List all installed packages by size

karol wrote:

If you have expac you can

expac "%n %m" -l'\n' -Q $(pacman -Qq) | sort -rkh 2 | less

And there's Allan's bigpkg

No need to call pacman.

expac -s "%-30n %m" | sort -rhk 2 | less

Offline

#10 2011-01-22 01:56:25

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: List all installed packages by size

falconindy wrote:
karol wrote:

If you have expac you can

expac "%n %m" -l'\n' -Q $(pacman -Qq) | sort -rkh 2 | less

And there's Allan's bigpkg

No need to call pacman.

expac -s "%-30n %m" | sort -rhk 2 | less
[karol@black ~]$ expac -s "%-30n %m" | sort -rhk 2 | less
error: bad token in format string: %-

Offline

#11 2011-01-22 02:06:00

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: List all installed packages by size

update expac.

Offline

#12 2011-01-22 02:14:48

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: List all installed packages by size

falconindy wrote:

update expac.

OK, now it does work :-)

Offline

#13 2011-01-23 11:42:28

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: List all installed packages by size

Ashren wrote:

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. smile

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

#14 2015-12-13 10:26:36

Shahab
Member
Registered: 2011-10-15
Posts: 30

Re: List all installed packages by size

Kooothor wrote:

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

big_smile

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

#15 2015-12-13 12:58:15

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,857
Website

Re: List all installed packages by size

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

Board footer

Powered by FluxBB