I'm learning the CLI interface of Advanced Packaging Tool. From the output of apt(8)
when its stdout isn't a terminal, it isn't suitable for "scripts expecting stable programming interface", so I'm taking a look at apt-get(8)
.
One difference between apt update
and apt-get update
is that the latter is missing a final line after all cache has been updated:
8 packages can be upgraded. Run 'apt list --upgradable' to see them.
I want to know how I can get this exact line displayed with apt-get(8)
.
man apt-get
shows:So if you just do:
apt-get upgrade --dry-run
it will output:
Guessing you need to handle the number of available updates, here is a suggestion:
No need to sudo
The output is easy to work with
More options:
From
man 8 apt
:Then I went through
/usr/share/doc/apt/examples/configure-index.gz
(usingzcat(1)
to show text content) and noticed this option:So I worked out the following command that did exactly what I wanted:
Tested to be working on Xenial and Bionic.