Many search terms take a string as a parameter and match it
against one or more fields of a package. Strings can be
entered either with or without double quotes
(“"
”), so
“
” and
“?name
(scorch)
” will
perform the same search. If you enter a search string using
double quotes, you can include a literal double-quote in the
search string by placing a backslash
(“?name
("scorch")\
”) immediately before it:
for instance,
“
”
will match any package whose description contains the string
“?description
("\"easy\"")"easy"
”.
If you enter a “bare” string, one not
surrounded by double quotes, then aptitude will consider
the string to have “ended” when it encounters
the closing parenthesis or the comma before a second
argument to the search term.
[14]
To remove the special meaning of these characters, place a
tilde (“~
”) directly before
them. For instance,
“
” is a
syntax error, because the first
“?description
(etc)))
” ends the ?description
term, and the second “)
”
does not correspond to any
“(
”. In contrast,
“
”
matches any package whose description contains the text
“?description
(etc~))etc)
”. There are
additional considerations if you are using the shorthand
notation for a term; see the section called “Shorthand for search terms” for details.
Most textual searches (for package names, descriptions, etc)
are performed using case-insensitive regular
expressions. A regular expression will match
against a field if any portion of the field matches the
expression; for instance,
“ogg[0-9]
” will match
“libogg5
”,
“ogg123
”, and
“theogg4u
”.
Some characters have a special meaning within regular
expressions
[15]
, so if you want to match them in searches you need to
backslash-escape them: for instance, to find
“g++
”, you should use the
pattern “g\+\+
”.
The characters “!
” and
“|
” have special meanings
within search patterns. In order to include these
characters in an unquoted string, you can place a tilde
(“~
”) directly before them.
For instance, to match packages whose description contains
either “grand” or “oblique”, use
the pattern
“
”.
However, you will probably find it more convenient to simply
use a quoted string in these cases:
“?description
(grand~|oblique)
”.
?description
("grand|oblique")
[14]
aptitude will only treat the comma as special if there
is a second argument, so (for instance)
“
”
searches for the string
“?name
(apt,itude)apt,itude
” in the
Name
field of packages.
While this behavior is well-defined, it may be surprising; I recommend using quoted strings for any pattern that contains characters that could have a special meaning.
[15]
Characters with a special meaning include:
“+
”,
“-
”,
“.
”,
“(
”,
“)
”,
“|
”,
“[
”,
“]
”,
“^
”,
“$
”, and
“?
”. Note that some of
these are also aptitude metacharacters, so if you want
to type (for instance) a literal
“|
”, it must be
double-escaped:
“
”
will match packages whose description contains a
vertical bar character
(“?description
(\~|)|
”).