Get all upgradable deb packages in a single line

apt list --upgradable | grep -v 'Listing...' | cut -d/ -f1 | tr '\r\n' ' ' | sed '$s/ $/\n/'
Works for debian and ubuntu based distros.
Sample Output
git-man git google-chrome-beta google-chrome-stable libnvidia-cfg1-430 libnvidia-common-430 libnvidia-compute-430 libnvidia-compute-430 libnvidia-decode-430 libnvidia-decode-430 libnvidia-encode-430 libnvidia-encode-430 libnvidia-fbc1-430 libnvidia-fbc1-430 libnvidia-gl-430 libnvidia-gl-430 libnvidia-ifr1-430 libnvidia-ifr1-430 libsmbclient libssh-4 libssh-gcrypt-4 libvulkan1 libvulkan1 libwbclient0 nvidia-compute-utils-430 nvidia-dkms-430 nvidia-driver-430 nvidia-kernel-common-430 nvidia-kernel-source-430 nvidia-utils-430 opera-stable python3-samba samba-common-bin samba-common samba-libs smbclient thunderbird-gnome-support thunderbird-locale-en-us thunderbird-locale-en thunderbird winbind xserver-xorg-video-nvidia-430

2
By: bugmenot
2019-12-13 16:16:19

What Others Think

apt list --upgradable | awk -vFS=/ 'NR > 1 { print $1 }' | paste -s -d ' ' is another way to do it ;-) The awk command skips the 'Listing...' line - as well as just outputs the first field. The paste idiom is pretty useful - It comes very handy for joining lines.
atul_s_khot · 81 weeks ago
apt list --upgradable | awk -vFS=/ 'NR > 1 { print $1 }' | paste -s -d ' ' is another way to do it ;-) The awk command skips the 'Listing...' line - as well as just outputs the first field. The paste idiom is pretty useful - It comes very handy for joining lines.
atul_s_khot · 81 weeks ago
learned alot thanks for this hair extensions spokane
looneyhans · 36 weeks and 1 day ago
It felt so good to know that I had a great company to call.baby photography They help a lot, thank you
idasanka · 31 weeks and 4 days ago
kitchen remodeling tacoma Whoa! I just can't believe I found this site
yeoyeo · 29 weeks and 6 days ago
Looked great afterward. Thank you so much, amazing job stairs
sammm · 26 weeks and 5 days ago
Worth it!! startup loan riverside
geebranz · 12 weeks ago
Good company unsecured loans laredo
geebranz · 11 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: