我正在学习高级打包工具的CLI接口。从apt(8)
的输出中,当它的stdout不是终端时,它不适合“脚本期望稳定的编程接口”,所以我来看看apt-get(8)
。
apt update
和apt-get update
的一个不同之处在于,在更新了所有缓存之后,后者缺少了最后一行:
8 packages can be upgraded. Run 'apt list --upgradable' to see them.
我想知道如何用apt-get(8)
显示这一行。
发布于 2019-03-25 06:34:30
man apt-get
显示:
-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.
所以如果你这么做:
apt-get upgrade --dry-run
它将输出:
...
4 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
...
发布于 2019-03-25 06:59:08
猜测您需要处理可用更新的数量,下面是一个建议:
# 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
没必要这么做
输出很容易使用。
更多选择:
> /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)
发布于 2019-03-25 06:30:39
来自man 8 apt
:
..。启用一些选项..。
然后我浏览了/usr/share/doc/apt/examples/configure-index.gz
(使用zcat(1)
显示文本内容)并注意到这个选项:
apt::cmd::show-update-stats
因此,我编写了以下命令,该命令完全符合我的要求:
# apt-get -o apt::cmd::show-update-stats=true update
测试是在做异能和仿生的工作。
https://askubuntu.com/questions/1128447
复制相似问题