[solved] 'dpkg-query -l' v.s. 'dpkg --get-selections'

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read this

[solved] 'dpkg-query -l' v.s. 'dpkg --get-selections'

Postby Jin Choi on Sat Mar 23, 2013 10:42 am

Hello, mint users ~_~
I only used to know 'dpkg --get-selections' command for list of installed or deinstalled packages in my machine. But today I learnt you can use another similar command for the similar result, 'dpkg-query -l'.

I wonder if they are totally the same or not.
I checked what it says on the man pages for each, but I want to know better than my rough guess.

FYI, I paste the manuals
dpkg --set-selections => Set package selections using file read from stdin. This file should be in the format 'package state', where state is one of install, hold, deinstall or purge. Blank lines and comment lines beginning with '#' are also permitted.

dpkg-query -l => List packages matching given pattern. If no package-name-pattern is given, list all packages in /var/lib/dpkg/status, excluding the ones marked as not-installed (i.e. those which have been previously purged). Normal shell wildchars are allowed in package-name-pattern. Please note you will probably have to quote package-name-pattern to prevent the shell from performing filename expansion.

And if they are practically the same, which one do you prefer and for what reason?
Thanks :)
Last edited by Jin Choi on Sat Mar 23, 2013 11:49 am, edited 1 time in total.
Jin Choi
Level 1
Level 1
 
Posts: 18
Joined: Fri Mar 22, 2013 2:52 am

Linux Mint is funded by ads and donations.
 

Re: 'dpkg-query -l' v.s. 'dpkg --get-selections'

Postby xenopeek on Sat Mar 23, 2013 10:55 am

Why not just `dpkg -l`? Output of course isn't identical, as dpkg -l / dpkg-query -l shows package version and summary while dpkg --get-selections just show list of installed package names.

Here you can see all three variants displaying 1880 installed packages. Line count for dpkg -l / dpkg-query -l is of course 5 higher, as I show afterwards the first five lines for those commands are the column headers and details.
Code: Select all
vincent@nadia ~ $ dpkg --get-selections | wc -l
1880
vincent@nadia ~ $ dpkg-query -l | wc -l
1885
vincent@nadia ~ $ dpkg -l | wc -l
1885
vincent@nadia ~ $ dpkg -l | head -n 10
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  accountsservic 0.6.21-6ubun amd64        query and manipulate user account
ii  acl            2.2.51-8ubun amd64        Access control list utilities
ii  acpi-support   0.141        amd64        scripts for handling many ACPI ev
ii  acpid          1:2.0.16-1ub amd64        Advanced Configuration and Power
ii  activity-log-m 0.9.4-0ubunt all          blacklist configuration for Zeitg
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14659
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: 'dpkg-query -l' v.s. 'dpkg --get-selections'

Postby Jin Choi on Sat Mar 23, 2013 11:49 am

xenopeek wrote:Why not just `dpkg -l`? Output of course isn't identical, as dpkg -l / dpkg-query -l shows package version and summary while dpkg --get-selections just show list of installed package names.

Here you can see all three variants displaying 1880 installed packages. Line count for dpkg -l / dpkg-query -l is of course 5 higher, as I show afterwards the first five lines for those commands are the column headers and details.
Code: Select all
vincent@nadia ~ $ dpkg --get-selections | wc -l
1880
vincent@nadia ~ $ dpkg-query -l | wc -l
1885
vincent@nadia ~ $ dpkg -l | wc -l
1885
vincent@nadia ~ $ dpkg -l | head -n 10
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  accountsservic 0.6.21-6ubun amd64        query and manipulate user account
ii  acl            2.2.51-8ubun amd64        Access control list utilities
ii  acpi-support   0.141        amd64        scripts for handling many ACPI ev
ii  acpid          1:2.0.16-1ub amd64        Advanced Configuration and Power
ii  activity-log-m 0.9.4-0ubunt all          blacklist configuration for Zeitg

Oh!!! I got it. I think I can stick to `dpkg -l` from now on.
Thank you very much xenopeek :)
Jin Choi
Level 1
Level 1
 
Posts: 18
Joined: Fri Mar 22, 2013 2:52 am


Return to Newbie Questions

Who is online

Users browsing this forum: astaroth, Google Adsense [Bot], JoeBingo and 17 guests