I would like to get the details about all the available packages in apt without installing them. I know that apt-cache search . would give me the list and description of all the available packages. However, I'm interested in the same list but with the most recent version. Is it possible?

I also know that I can loop over the package names and run apt-cache show pkgName, but I do not want to make multiple queries to apt-cache. I want to query it only once or use another tool or another available resource that could give me this info.

Edit: I would like the output to be something like this on each line:

package1, version
package2, version

And version, is the most recent version available in apt repository.

  • Do I misunderstand you or apt-cache show . helps? – schrodigerscatcuriosity Sep 26 '19 at 19:35
  • Thanks for your comment. I like the output to be something like this on each line: packageName, most recent version – Sida Sep 26 '19 at 19:42
  • 5
    This seems like an XY Question. What is the purpose of this output format? Why would anybody want a list of thousands of package names and their current versions? – user535733 Sep 26 '19 at 19:45
  • 1
    Totally agree with @user535733 . Please also note that the output of apt-cache policy . might be a bit easier to parse than the one of apt-cache show, in case you want to script its parsing. – dadexix86 Sep 26 '19 at 19:48

One easy answer to your question is to use dpkg instead of apt. apt will happily do all the logic and keep track of the versions precisely so you needn't muck around with such tedious details.

This particular command shows currently-installed versions, not available-for-upgrade (use apt list --upgradeable for that)

Try dpkg -l | grep ii | awk '{print$2, $3}' | sed 's/ /, /'

  • Use dpkg -l to get the complete list of packages and versions in your package database
  • Limit the output by showing only installed (ii) packages: grep ii
  • Use awk to print only the second and third columns with : awk '{print$2, $3}'
  • Insert your comma using sed: sed 's/ /, /'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.