I guess i
is installed, but the others?
$ apt search * | sort -t' ' -k1 | cut -c1 | uniq
c
i
p
v
apt search
’s output takes the form
package name/suites version architecture [state]
description
so extracting the first column won’t give much useful information.
Addressing your updated question from your comment, “how to know search and check for installed at the same time?”, you can use
apt search $pattern | grep -A1 '\[.*installed.*\]'
This will show the installed packages matching $pattern
; for example on my system
$ apt search evdev | grep -A1 '\[.*installed.*\]'
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
evemu-tools/stable,now 2.7.0-1 amd64 [installed,automatic]
Linux Input Event Device Emulation Library - test tools
--
joystick/stable,now 1:1.6.1-1 amd64 [installed]
set of testing and calibration tools for joysticks
--
libevdev-build-deps/now 1.6.0+dfsg-1 all [installed,local]
build-dependencies for libevdev
--
etc.
The warning is irrelevant here; you can’t avoid it by using apt-cache
instead because apt-cache
doesn’t show all the information needed.
You can also use aptitude
:
aptitude search '~i evdev`
will search for installed packages matching “evdev”.
apt search
on my platform/setup does not specify [state]
in any column. So, this does not solve my question.
$ uname -a; cat /etc/*-release | grep DISTRIB_DESCRIPTION Linux laptop 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux cat: /etc/upstream-releaseDISTRIB_DESCRIPTION="Linux Mint 19 Tara"
ls
, in the same directory you ran theapt
command above?ls
be relevant? I think it was from the directory created bytar emacs-26.3.tar.xz
.apt search *
expands*
with the names of the files in the current directory..*
, unless you quoted them or escaped the*
. But unlikeaptitude search
which the linked question refers to,apt search
andapt-cache
search output the package name first, so the first character in the line wouldn’t give you any information about the state of the package.