Re: Getting a list of installed packages
Robert Guthrie <firstname.lastname@example.org> wrote:
>I'm using this command:
>dpkg -l * | egrep "^ii" | grep -i kde
>and getting this output:
>ii ksirc 2.0-final-0.po IRC Client based on QT and KDE
>ii ksirtet 2.0-final-0.po Tetris and Puyo-Puyo games for KDE
>What I'm trying to get is the full version information. I only care about
>that and the package name.
'dpkg -l' is designed to produce output that looks reasonable on the
screen, so sometimes it has to truncate version numbers. In an X
terminal, resizing the terminal will cause it to produce wider output;
otherwise (e.g. to a pipe), dpkg-1.7.0 and above (only in woody) will
look at the COLUMNS environment variable to determine the width of the
display for which the output should be formatted.
If you're automatically processing the output, however, 'dpkg -l' isn't
really the right tool to use. For individual packages you can do
something like 'dpkg -s foo | grep ^Version:'. For the sort of search
you're doing you should really install the grep-dctrl package, and then
you can do this:
grep-status -i kde | \
grep-dctrl -sPackage,Version -FStatus 'install ok installed'
grep-dctrl and friends are very useful tools indeed.
Colin Watson [email@example.com]