Edit: Please note, as written below, I'm aware of answers on this site explaining that
apt-get uses regex to interpret packages' names. In fact, the question is directly about a way in which its actual behavior is different from that documented one. Please read the question before suggesting a duplicate.
Some answers on this site warn about using
apt-get with wildcards (i.e., asterisks:
apt-get supposedly expands them as regular expressions, which might give unexpected (and undesired) results, especially with
apt-get remove. Indeed, Ubuntu
man page for
If no package matches the given expression and the expression contains
one of '.', '?' or '*' then it is assumed to be a POSIX regular
expression, and it is applied to all package names in the database.
Any matches are then installed (or removed). Note that matching is
done by substring so 'lo.*' matches 'how-lo' and 'lowest'. If this is
undesired, anchor the regular expression with a '^' or '$' character,
or create a more specific regular expression.
In fact, this answer claims:
apt-get accepts a regular expression and not a glob pattern as the shell.
I believe this is wrong (at least as of Xenial). For example, I can reproduce the following behavior:
$ sudo apt-get install -s 'meld*' [...] Note, selecting 'meld' for glob 'meld*' [...] $ sudo apt-get install -s 'meldt*' [...] Note, selecting 'python-meld3' for regex 'meldt*' Note, selecting 'python3-meld3' for regex 'meldt*' Note, selecting 'meld' for regex 'meldt*' [...]
(I didn't remove any matches, only irrelevant parts of
It would seem to me, based on this behavior, that
apt-get first attempts to match given expressions as globs, and only if it fails, will it then retry as regular expressions.
Do I have that right? Have I misunderstood the
man page, or is this behavior badly documented?