Get list of installed packages
It has been asked before, but with different answers, e.g.: 1) dpkg-query --list | awk '/^ii +/ { print $2; }' 2) dpkg --get-selections | cut -f 1 3) ... etc ... Given that the output is the same: $ diff \ (dpkg --get-selections | cut -f 1) \ (dpkg-query --list | awk '/^ii +/ { print $2; }') \ echo same-output same-output I wonder, what's the golden way to do this and why? -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52f388e4.6000...@gmail.com
Re: Get list of installed packages
Tino Sino writes: It has been asked before, but with different answers, e.g.: 1) dpkg-query --list | awk '/^ii +/ { print $2; }' 2) dpkg --get-selections | cut -f 1 3) ... etc ... Given that the output is the same: $ diff \ (dpkg --get-selections | cut -f 1) \ (dpkg-query --list | awk '/^ii +/ { print $2; }') \ echo same-output same-output I wonder, what's the golden way to do this and why? What's wrong in dpkg -l | grep ii (you could use grep -e '^ii') or egrep '^ii', but I think it's not worth the cpu used). -- /\ ___Ubuntu: ancient /___/\_|_|\_|__|___Gian Uberto Lauri_ African word //--\| | \| | Integralista GNUslamicomeaning I can \/ coltivatore diretto di software not install giĆ sistemista a tempo (altrui) perso...Debian Warning: gnome-config-daemon considered more dangerous than GOTO -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/21235.35406.928239.298...@mail.eng.it
Re: Get list of installed packages
?? Thu, 06 Feb 2014 14:06:44 +0100 Tino Sino robottinos...@gmail.com : It has been asked before, but with different answers, e.g.: 1) dpkg-query --list | awk '/^ii +/ { print $2; }' 2) dpkg --get-selections | cut -f 1 3) ... etc ... Given that the output is the same: $ diff \ (dpkg --get-selections | cut -f 1) \ (dpkg-query --list | awk '/^ii +/ { print $2; }') \ echo same-output same-output I wonder, what's the golden way to do this and why? dpkg -l It's simple. Nothing is really golden or best, I think. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20140206211706.2279a255@debian
Re: Get list of installed packages
On 02/06/2014 08:17 AM, iijima yoshino wrote: ?? Thu, 06 Feb 2014 14:06:44 +0100 Tino Sino robottinos...@gmail.com : It has been asked before, but with different answers, e.g.: 1) dpkg-query --list | awk '/^ii +/ { print $2; }' 2) dpkg --get-selections | cut -f 1 3) ... etc ... Given that the output is the same: $ diff \ (dpkg --get-selections | cut -f 1) \ (dpkg-query --list | awk '/^ii +/ { print $2; }') \ echo same-output same-output I wonder, what's the golden way to do this and why? dpkg -l It's simple. Nothing is really golden or best, I think. because to use the package list for an install/reinstall you need to use set-selections, like this: --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. -- Paul Cartwright Registered Linux User #367800 and new counter #561587 -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52f38e5c.8050...@gmail.com
Re: Get list of installed packages
On 06/02/2014 14:06, Tino Sino wrote: It has been asked before, but with different answers, e.g.: 1) dpkg-query --list | awk '/^ii +/ { print $2; }' 2) dpkg --get-selections | cut -f 1 3) ... etc ... Given that the output is the same: $ diff \ (dpkg --get-selections | cut -f 1) \ (dpkg-query --list | awk '/^ii +/ { print $2; }') \ echo same-output same-output I wonder, what's the golden way to do this and why? Personaly, I use this: aptitude search ~i\!~M --disable-columns -F %p aptitude-packages.txt options: ~i : installed packages \!~M : not automatically installed, in combination with ~i this means you'll get a list of packages names you asked to =aptitude install ...= explicitly (and not their respective dependencies) -F %p : format output to print only column of (untruncated) packages names --disable-columns : disable trailing padd of white-spaces at the end of lines (in my opinion, this should be better handled by aptitude, i.e., no padding when only one column is to be displayed, etc.) Then restore packages this way: aptitude install $(cat aptitude-packages.txt) Why do I use this? Aptitude stores a flag for packages that were automatically installed. This is handy since the packages list you have to preserve is really shorter than the whole installed packages list. It makes this list human readable and editable. Nicolas -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52f3936a.8030...@yahoo.fr
Re: Get list of installed packages
On 06/02/2014 13:12, Gian Uberto Lauri wrote: (you could use grep -e '^ii') or egrep '^ii', but I think it's not worth the cpu used). You don't need -e to use anchors in the regex. Whilst -e would use more CPU than a plain grep, the anchor would likely reduce the work done (lines can be matched or discarded on the first character) -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52f3a738.1030...@debian.org
Re: Get list of installed packages
On 06/02/2014 13:06, Tino Sino wrote: I wonder, what's the golden way to do this and why? It depends on what you're doing it for. If it's for a script, dpkg-query is a better choice, because you can do --showformat and it does not truncate version strings etc. 'dpkg -l' output is really meant for humans only, and you need to perform a few contortions to get a reliable output for scripts (COLUMNS=255 dpkg -l ... etc.); and you can't guarantee compatibility with future dpkg output. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52f3a7ab.8050...@debian.org