我正在学习 Advanced Packaging Tool 的 CLI 界面。从apt(8)它的 stdout 不是终端时的输出来看,它不适合“需要稳定编程接口的脚本”,因此我正在查看apt-get(8).
apt update和之间的一个区别apt-get update是后者在所有缓存更新后缺少最后一行:
8 packages can be upgraded. Run 'apt list --upgradable' to see them.
Run Code Online (Sandbox Code Playgroud)
我想知道如何使用apt-get(8).
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.
Run Code Online (Sandbox Code Playgroud)
所以如果你只是这样做:
apt-get upgrade --dry-run
它会输出:
...
4 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
...
Run Code Online (Sandbox Code Playgroud)
从man 8 apt:
...启用一些选项...
然后我浏览/usr/share/doc/apt/examples/configure-index.gz(用于zcat(1)显示文本内容)并注意到这个选项:
apt::cmd::show-update-stats
Run Code Online (Sandbox Code Playgroud)
所以我制定了以下命令,它完全满足了我的要求:
# apt-get -o apt::cmd::show-update-stats=true update
Run Code Online (Sandbox Code Playgroud)
经测试可在 Xenial 和 Bionic 上运行。
| 归档时间: |
|
| 查看次数: |
2178 次 |
| 最近记录: |