小编Cor*_*ter的帖子

如何禁用“警告:apt 没有稳定的 CLI 界面...”

我正在尝试编写一个脚本,该脚本将从 apt 输出可升级包的数量。然而,它也不断给我这个警告:

# sudo apt update | grep packages | cut -d '.' -f 1

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

All packages are up to date
Run Code Online (Sandbox Code Playgroud)

我希望它只输出:

All packages are up to date
Run Code Online (Sandbox Code Playgroud)

或者

35 packages can be updated
Run Code Online (Sandbox Code Playgroud)

有什么办法可以禁用该警告吗?我将在来自 cron 作业的 Discord 通知中使用这个返回的字符串以及一些额外的信息,它非常糟糕地搞乱了我的输出。

我已经看过这些,但没有一个对我有用:

https://askubuntu.com/questions/49958/how-to-find-the-number-of-packages-needing-update-from-the-command-line

https://unix.stackexchange.com/questions/19470/list-available-updates-but-do-not-install-them

https://askubuntu.com/questions/269606/apt-get-count-the-number-of-updates-available

linux bash command-line-interface apt raspbian

17
推荐指数
2
解决办法
4万
查看次数

标签 统计

apt ×1

bash ×1

command-line-interface ×1

linux ×1

raspbian ×1