list of installed packages without using apt?

Xen list at xenhideout.nl
Tue Nov 28 03:30:57 UTC 2017


Stuart McGraw schreef op 27-11-2017 23:18:
> Is there some way of getting output similar to 'apt list --installed'
> without using apt?  Specifically I want a list of installed packages,
> their version numbers, and whether they were installed at my request
> or as a dependency.  dpkg-query provides the first two items and I
> think apt-mark the last, but the problem is combining them.
> 
> I dont want to use apt because: 1) I am using in a shell script and
> apt prints an annoying warning, 2) The warning recommends against
> using apt in scripts :-)  I want to use basic low-level commands
> and not large complex things like apt or aptitude.

The problem is more apt being annoying than apt being bad.

If you wanted to combine dpkg and apt-mark you would get something like:


dpkg -l | grep "^ii" | awk {'print $2'} | while read name; do
     # now process version string
     version=${name#*-}
     name=${name%-*-*}
     apt-mark showmanual | grep -Fx "$name" && manual=yes || manual=
done




More information about the ubuntu-users mailing list