26

When I run this command :

apt install libkf5*

I get the following error :

Unable to locate package libkf5*


I'm sure that the packages whose names start with libkf5 exist (tab-completion says so) . So the problem is not about the absence of those packages.(Note the asterisk at the end of that error message , the wildcard's not working at all)
I use apt v.1.9.
Thanks in advance.

αғsнιη
  • 36,350

5 Answers5

26

Recent versions of apt changed the way patterns are specified, and apt no longer supports regular expressions directly or wildcards, other than * for which support was restored in 2.1.0 and backported to 2.0.3.

You should now use

apt install '~nlibkf5.*'

with apt between 1.9.9 and 2.0.2, or the long form

apt install '?name(libkf5.*)'

available slightly earlier.

See the apt-patterns manpage (man apt-patterns) for details.

Stephen Kitt
  • 1,539
8

One can still use plain apt-get for such purpose.

For the OP's example it will look like

sudo apt-get install "libkf5*"

N0rbert
  • 103,263
3

Per the changelog of apt, version 2.1.0:

* Reinstate * wildcards (Closes: #953531) (LP: #1872200)

(Link: Launchpad #1872200)

The asterisk (and only asterisk) has been restored for all apt subcommands, including apt install.

While 2.1.0 is too new to be shipped to Focal, it's been backported to 2.0.3 which is available in the focal-proposed repository. You can refer to the Ubuntu Wiki for enabling the Proposed repository, and then you can install apt 2.0.3 which has this feature backported.

See for yourself:

image

Note: You may want to read What is the "proposed" repository? before proceeding with the Proposed repository.

iBug
  • 1,859
2

Ubuntu 20.04 introduced Apt 2.0

From the Release Notes:

New Features

  • Commands accepting package names now accept aptitude-style patterns. The syntax of patterns is mostly a subset of aptitude, see apt-patterns(7) for more details.

Incompatibilities

  • The apt(8) command no longer accepts regular expressions or wildcards as package arguments, use patterns (see New Features).
user535733
  • 68,493
1

I found a small trick to use apt with wildcard. We just need to alias apt with apt-get, but this method doesn't work because aliases are not passed to sudo. To pass out this problem, you can add an second alias for sudo in your .bashrc file:

alias sudo='sudo ' # whitespace is important 
alias apt='apt-get'

Credits:

Kulfy
  • 18,154