1

I guess i is installed, but the others?

$ apt search * | sort -t' ' -k1 | cut -c1 | uniq
c
i
p
v
  • 3
    Could you edit your question to show the output of ls, in the same directory you ran the apt command above? – Stephen Kitt Oct 29 '19 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 '19 at 21:52
  • 3
    @Erwann it’s relevant because apt search * expands * with the names of the files in the current directory. – Stephen Kitt Oct 29 '19 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. – Stephen Kitt Oct 30 '19 at 9:35
1

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

|improve this answer|||||
  • "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 '19 at 7:19
  • Would you mind clarifying what platform you’re using? – Stephen Kitt Nov 2 '19 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 '19 at 7:59
  • Try aptitude then, see my updated answer. – Stephen Kitt Nov 2 '19 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.