Fedora documentation says:
5.2. Advanced Searches
If you do not know the name of the package, use the search or provides options. Alternatively, use wild cards or
regular expressions with any yum search option to broaden the search
critieria.
Well, at first I thought that this is simply wrong or outdated, since no known syntax of regular expressions would work with yum search
, but then I found this: yum search [cl-*]
for example. But it does something otherworldly. It finds things which have neither "c" nor "l" letters in the name or description. (What I wanted is to find all packages, whose names would be matched by cl-.*
regexp.
I also found few people suggesting to pipe yum results to grep
, which, of course, solves the problem. But, just on principle, I want to find out what did the thing in the square brackets do. What if yum
actually can search by regexp?
Best Answer
searching with YUM
You generally don't use any regular expressions (globs) when searching with
yum search
since the commandsearch
is already looking for sub-strings within the package names and their summaries. How do I know this? There's a message that tells you this when you useyum search
.NOTE: The string
[cl-*]
is technically a glob in the Bash shell.So you generally look for fragments of strings that you want with
For example:search
. The regular expressions come into play when you're looking for particular packages. These are the YUM commands likelist
andinstall
.The only caveat you have to be careful with regexes/globs, is if there are files within your shell that are named such that they too would match
cl-*
. In those cases your shell will expand the regex/glob prior to it being presented to YUM.So instead of running
For example:yum list cl-*
you'll be running the commandyum list cl-file
, if there's a file matching the regex/globcl-*
.You can guard against this happening by escaping the wildcard like so:
So what about the brackets
I suspect you have files in your local directory that are getting matched when you used
For example:[cl-*]
as an argument toyum search
. These files after being matched by the shell, were passed to theyum search
command where matches where then found.NOTE: The match above was matched against my file's name,
cl-file
, and not thecl-*
as I had intended.