Results 1 to 3 of 3

Thread: LIst all installed packages in size order

  1. #1
    Join Date
    Sep 2006
    Beans
    5

    LIst all installed packages in size order

    The ugliest script in the world:

    aptitude show '~n.*' | awk -f fix | grep 'State: installed' | sed 's/: /:/g' | sort -t: -n -k4 | more

    Where "fix" is

    /^Package:/ {p = $0}
    /^State:/ {s = $0}
    /^Uncompressed Size:/ {print p " " s " " $0}

  2. #2
    Join Date
    Feb 2007
    Location
    perdita
    Beans
    1,625
    Distro
    Ubuntu

    Re: LIst all installed packages in size order

    I was trying to find another one I used some time ago with dpkg and found this post instead.

    Found it:
    Code:
    dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1n
    Others I found on the way:
    Code:
    dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' | sort -k 2 -n
    Code:
    dpkg-query --show --showformat='${Package;-50}\t${Installed-Size} ${Status}\n' | sort -k 2 -n |grep -v deinstall
    source: http://ubuntuforums.org/showthread.php?t=602270

    In case somebody is looking for this too.

    And for those wanting a GUI: Just sort by installed size in Synaptic. ^^

    edit:
    Made a script allowing you to test all of those methods (also shows how to embed the awk script into the shellscript. ).

    list_installed_packages_by_size.sh:
    Code:
    #!/bin/bash
    if [ $# -ne 1 ]
    then
            echo "usage : $0 <0/1/2/3>"
            exit 0 
    fi
    
    if [ $1 -eq 0 ]
    then
    	aptitude show '~n.*' | awk '\
    	/^Package:/ {p = $0};\
    	/^State:/ {s = $0};\
    	/^Uncompressed Size:/ {print p " " s " " $0};\
    	' | grep 'State: installed' | sed 's/: /:/g' | sort -t: -n -k4 | more
    fi
    
    if [ $1 -eq 1 ]
    then
    	dpkg-query -W --showformat='${Installed-Size;10}\t${Package}\n' | sort -k1,1n
    fi
    
    if [ $1 -eq 2 ]
    then
    	dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' | sort -k 2 -n
    fi
    
    if [ $1 -eq 3 ]
    then
    	dpkg-query --show --showformat='${Package;-50}\t${Installed-Size} ${Status}\n' | sort -k 2 -n |grep -v deinstall
    fi
    Last edited by KIAaze; April 9th, 2010 at 04:35 PM.

  3. #3
    Join Date
    Feb 2007
    Location
    perdita
    Beans
    1,625
    Distro
    Ubuntu

    Re: LIst all installed packages in size order

    Even better: wajig or dpigs!
    cf: http://www.commandlinefu.com/command...n-debianubuntu

    Code:
    sudo apt-get install wajig
    wajig large
    Code:
    sudo apt-get install debian-goodies
    dpigs

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •