LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   listing the installed Packages (http://www.linuxquestions.org/questions/linux-newbie-8/listing-the-installed-packages-595160/)

nmansour 10-28-2007 01:48 AM

listing the installed Packages
 
Hi,

Is there a command which I can use to list all the packages I have on my system with their sizes? "The sizes which they occupy on my HDD".

Noha

jschiwal 10-28-2007 02:07 AM

You can use "rpm -qa" to list all packages. To list the total size of the files in the package, I think you will need to use the --dump option to give you the block size of each file, and then use something like awk to give you the total.

Code:

rpm -q --dump kdeutils3 | awk '{size+=$2}END{print size}'

nmansour 10-28-2007 02:18 AM

Thanks,

Here is the output:
Code:

[noha@hep-ex ~]$ rpm -q --dump kdeutils3 | awk '{size+=$5}END{print size}'
0
[noha@hep-ex ~]$

Did I do it right?

Noha

jschiwal 10-28-2007 02:29 AM

You probably don't have the kdeutils3 package installed.

This will list all of the packages and their sizes:
Code:

function packsize { rpm -q --dump $1 | awk '{size+=$2}END{print size}'; }
for package in $(rpm -qa); do
  echo -ne "$package\t"
  packsize "$package"
done


nmansour 10-28-2007 02:16 PM

It worked like a charm! Thank you

but how may I display the sizes in KB?


Also, was this a bash script (with an awk one)?


Noha


All times are GMT -5. The time now is 04:43 PM.