How to search only 'not-installed' packages in Arch Linux?
What flags can one use with pacman -S
to show only those packages, that aren’t yet installed?
Will accept shell script if it can’t be done by design. Thx.
After first try was the inverse answer, thanks Jeff Schaller. Here’s a little script that filters out installed packages and only displays not installed packages.
#!/bin/sh
installed=$(pacman -Q | cut -d ' ' -f 1 | tr 'n' '|')
pacman -Ssq | egrep -v '${installed}'
here is a script with 3 different methods, all keeping the one line description. also it lets you do search terms with command line arguments
#!/bin/bash
#pacman -Ss "$@" | pcregrep -Mv '.*[installed.*n'
#pacman -Ss "$@" | sed -n -e '/[installed/!p;: m' -e '//{' -e '$!{' -e 'n;b m' -e '}' -e'}'
pacman -Ss "$@" | awk '/[installed/ { getline; next } 1'
example:
pacman-search-exclude-installed.sh search terms
my research:
How to grep -v and also exclude the next line after the match?
How to `grep -v` and also exclude 'n' lines after the match?
expanding on @thomas answer here are some ready to go functions you can source and use to achieve OPs question
pmig () {
pacman -Q | grep $1 | cut -d ' ' -f 1
}
pmrg () {
pacman -Ssq | grep $1
}
pmnig () {
local installed="|$(pmig $1 | tr 'n' '|')"
pmrg $1 | grep -E -v '${installed}'
}
pmnigv () {
pacman -Ss $1 | grep -v "$(pacman -Ss $1 | grep "[installed]" -A1 )" | grep -v "[installed]"
}
then trying out.
echo "==installed =="; pmig disk; echo "==in repos=="; pmrg disk; echo "===in repos but not installed==="; pmnig disk
results in
==installed ==
gnome-disk-utility
gptfdisk
udiskie
udisks2
==in repos==
gnome-disk-utility
gptfdisk
plasma-disks
testdisk
udisks2
xfce4-diskperf-plugin
deepin-diskmanager
diskonaut
diskus
haskell-disk-free-space
kdiskmark
udiskie
udisks2-qt5
xdiskusage
yubikey-full-disk-encryption
===in repos but not installed===
plasma-disks
testdisk
xfce4-diskperf-plugin
deepin-diskmanager
diskonaut
diskus
haskell-disk-free-space
kdiskmark
xdiskusage
yubikey-full-disk-encryption
an pmnigv is a verbose version
pmigv disk
extra/cdrdao 1.2.5-1
Records audio/data CD-Rs in disk-at-once (DAO) mode
extra/filelight 22.12.2-1 (kde-applications kde-utilities)
View disk usage information
extra/kdf 22.12.2-1 (kde-applications kde-utilities)
View Disk Usage
extra/libisofs 1.5.4-1
Library to pack up hard disk files and directories into a ISO 9660 disk image
extra/mtools 1:4.0.42-1
A collection of utilities to access MS-DOS disks
extra/partitionmanager 22.12.2-1 (kde-applications kde-system)
A KDE utility that allows you to manage disks, partitions, and file systems
extra/plasma-disks 5.26.5-1 (plasma)
Monitors S.M.A.R.T. capable devices for imminent failure
extra/qemu-img 7.2.0-3
QEMU tooling for manipulating disk images
....