I guess i is installed, but the others?

$ apt search * | sort -t' ' -k1 | cut -c1 | uniq
  • 3
    Could you edit your question to show the output of ls, in the same directory you ran the apt command above? Oct 29, 2019 at 21:22
  • @StephenKitt how would ls be relevant? I think it was from the directory created by tar emacs-26.3.tar.xz.
    – Erwann
    Oct 29, 2019 at 21:52
  • 3
    @Erwann it’s relevant because apt search * expands * with the names of the files in the current directory. Oct 29, 2019 at 22:43
  • 3
    @Erwann those would have had the same problem, expanding .*, unless you quoted them or escaped the *. But unlike aptitude search which the linked question refers to, apt search and apt-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. Oct 30, 2019 at 9:35

1 Answer 1


apt search’s output takes the form

package name/suites version architecture [state]

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


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”.

  • "so extracting the first column won’t give much useful information": that's a straw man since I had already acknowledged I had mistaken the first column for the state. Output of apt search on my platform/setup does not specify [state] in any column. So, this does not solve my question.
    – Erwann
    Nov 2, 2019 at 7:19
  • Would you mind clarifying what platform you’re using? Nov 2, 2019 at 7:49
  • $ 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"
    – Erwann
    Nov 2, 2019 at 7:59
  • Try aptitude then, see my updated answer. Nov 2, 2019 at 8:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .