On Ubuntu 22.04.3:
paul@box4x4:~$ apt search libstdc++ | grep installed
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libstdc++-11-dev/jammy-updates,jammy-security,now 11.4.0-1ubuntu1~22.04 amd64 [installed,automatic]
libstdc++-12-dev/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 amd64 [installed]
libstdc++6/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 amd64 [installed,automatic]
which shows that libstdc++-12-dev
is already installed. Searching for it with:
paul@box4x4:~$ apt search libstdc++-12-dev
Sorting... Done
Full Text Search... Done
fails. Why is that?
Run
apt search libstdc\\+\\+-12-dev
instead.man apt
says:No, this is not a problem with
bash
expansion. If it was doing expansion,echo
will help you debug what it is expanding to:The problem is that you wrote
libstdc++-12-dev
. This, when interpreted as a RegEx, means:libstd
literallyc
literally-12-dev
literallyapt search 'libstdc\+\+-12-dev'
works just as well asapt search libstdc\\+\\+-12-dev
. To escape the backslashes frombash
, you either need to quote or double them. Then, theapt
RegEx engine needs a backslash to tell it to interpret+
as a literal string instead of "one or more of the preceding."