Specifying the Search Query
By default, the search query is a series of terms to be matched exactly except for case. Use the -I
option to specify a case-sensitive search.
You can use ?
and *
wildcards in query terms. You can use single or double quotation marks to search for phrases. Be sure to take your shell into account when you use wildcards or quotation marks.
You can specify more than one query term. By default, multiple terms are joined with AND. You can explicitly join two terms with OR.
Search queries can be expressed in the following structured form:
package:action:index:token
- package
-
The name of the package to search or a pattern that might match multiple packages.
- action
-
The name of an action listed in the Actions section in the
pkg
(7) man page. - index
-
Usually selects an attribute of action as listed in the Actions section of the
pkg
(7) man page. See below for more information. - token
-
The value of index or a pattern that might match the value of index.
Missing fields are implicitly wildcarded. The token string can be explicitly wildcarded. Names of actions and indexes cannot be explicitly wildcarded.
The index is not necessarily the same as the name of an action attribute. For example, the index for the user
action is name
, while the name of that attribute is username
.
Not all action attributes are searchable. For example, mode
is an attribute of the file
action, but mode
is not a valid value for index.
The following example shows one way to find all possible indexes for an action:
$ pkg search :user::
This command shows that the only searchable attribute of a user
action is name
.
Some values of index are values derived from other attributes. For example, index can be basename
, which is the last component of the path
attribute of a file
or dir
action. Examples of useful values for index include basename
and path
for file
and dir
actions, the dependency type (require
or group
, for example) for depend
actions, and driver_name
and alias
for driver
actions.
The index can also be a special pseudo attribute name such as action.key
(the key attribute of the action) or pkg.name
. See the pkg
(1) man page for a complete list.
The value of token is compared with the value of the attribute named by index. For example, in the following partial driver
action, alias
is an attribute name that could be specified for index, and pci14e*
could be specified for token.
driver alias=pci14e4,1000 alias=pci14e4,1200 alias=pci14e4,1203
By default, results are displayed for all matching actions, which can yield multiple lines of results for one package. Use the -p
option to list each matching package only once.
$ pkg search -Hpo pkg.name driver:alias:pci14e\*
driver/network/ethernet/bge
driver/network/ethernet/bnx
driver/network/ethernet/bnxe
The syntax of a set
action is slightly different. The two attributes of a set
action are name
and value
. In this case, the value of index is the value of a name
attribute, and the value of token is compared with the value of the matching value
attribute. The following example shows a set
action for a driver package:
set name=pkg.summary value="QLogic 57xxx 10/20GbE NIC Driver"
The following example specifies *driver*
for package name, pkg.summary
for index, and qlogic
for token. The set
action is implied because the pkg.summary
attribute only applies to a set
action. The search.match
and pkg.name
column specifiers are pseudo attributes. See the pkg
(1) man page.
$ pkg search -o search.match,pkg.name \*driver\*::pkg.summary:qlogic
SEARCH.MATCH PKG.NAME
QLogic 570x/571x Gigabit Ethernet Driver driver/network/ethernet/bnx
QLogic 57xxx 10/20GbE NIC Driver driver/network/ethernet/bnxe
QLogic ISP Fibre Channel device storage and NIC driver driver/fc/qlc
QLogic P3+ 10GbE NIC Driver driver/network/ethernet/qlcnic
The following command gives the same result as the preceding command:
$ pkg search -o search.match,pkg.name pkg.summary:'qlogic * driver'
Some well-defined values of set
action name
attributes include pkg.fmri
, info.classification
, pkg.description
, and pkg.summary
. See Set Actions in the pkg
(7) man page.
By default, matches are displayed only for currently installed or newer package versions. Use the -f
option to display all matched versions.