Score:0

how to list all upgradable packages without using apt

kr flag

I have a script like this.

#!/bin/sh

apt-get update

[ "$(apt list --upgradable 2>/dev/null | grep -c upgradable)" -gt 0 ] &&
apt-get upgrade --with-new-pkgs -y &&
apt-get autoremove -y &&
apt-get autoclean -y

only problem is that everytime I run this, it shows warning about apt not having a stable cli. How can I list all upgradable packages without apt?
On apt manpage it says that apt list is similar to dpkg-query, but I could not find a way to list upgradable packages using dpkg-query.

edit: I am using Ubuntu 20.04.3 LTS

us flag
Which version of ubuntu are you using? `apt` does have a stable cli in the recent versions of Ubuntu.
us flag
Does this answer your question? [Equivalent command for --upgradable in apt-get](https://askubuntu.com/questions/1332550/equivalent-command-for-upgradable-in-apt-get) Short answer - Use `apt-get --just-print upgrade` instead of `apt list --upgradable`).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.