Make "apt-get update" show the exact output as `apt update`

Solution 1:

man apt-get shows:

   -s, --simulate, --just-print, --dry-run, --recon, --no-act
       No action; perform a simulation of events that would occur based on
       the current system state but do not actually change the system.
       Locking will be disabled (Debug::NoLocking) so the system state
       could change while apt-get is running. Simulations can also be
       executed by non-root users which might not have read access to all
       apt configuration distorting the simulation. A notice expressing
       this warning is also shown by default for non-root users
       (APT::Get::Show-User-Simulation-Note). Configuration Item:
       APT::Get::Simulate.

So if you just do:

apt-get upgrade --dry-run

it will output:

...
4 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
...

Solution 2:

Guessing you need to handle the number of available updates, here is a suggestion:

# With no option, returns two numbers, no CR nor LF
/usr/lib/update-notifier/apt-check

# With --human-readable, returns numbers, locale LANG text & CR/LF
/usr/lib/update-notifier/apt-check  --human-readable

No need to sudo
The output is easy to work with

More options:

> /usr/lib/update-notifier/apt-check  --help
Usage: apt-check [options]

Options:
  -h, --help            show this help message and exit
  -p, --package-names   Show the packages that are going to be
                        installed/upgraded
  --human-readable      Show human readable output on stdout
  --security-updates-unattended
                        Return the time in days when security updates are
                        installed unattended (0 means disabled)

Solution 3:

From man 8 apt:

... enables some options ...

Then I went through /usr/share/doc/apt/examples/configure-index.gz (using zcat(1) to show text content) and noticed this option:

apt::cmd::show-update-stats

So I worked out the following command that did exactly what I wanted:

# apt-get -o apt::cmd::show-update-stats=true update

Tested to be working on Xenial and Bionic.