Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
PKG-QUERY(8)		     System Manager's Manual		    PKG-QUERY(8)

NAME
     pkg query -- query information for packages

SYNOPSIS
     pkg query <query-format> <pkg-name>

     pkg query [-a] <query-format>
     pkg query -F <pkg-file> <query-format>
     pkg query [-Cgix] [-e <evaluation-condition>] <query-format> <pattern>
	 <...>

     pkg query [--all] <query-format>
     pkg query --file <pkg-file> <query-format>
     pkg query [--{case-sensitive,glob,case-insensitive,regex}]
	 [--evaluate <evaluation-condition>] <query-format> <pattern> <...>

DESCRIPTION
     pkg query is used for displaying information about packages.

OPTIONS
     The following options are supported by pkg query:

     -a, --all
	       Match all packages from the database

     -C, --case-sensitive
	       Make the standard or the regular expression (-x) matching against
	       pkg-name  in pattern case sensitive.  This is the default, unless
	       modified by setting CASE_SENSITIVE_MATCH to false in pkg.conf.

     -e, --evaluate
	       Match  packages	using  the  given   evaluation-condition.    See
	       "EVALUATION FORMAT" for details.

     -F pkg-file, --file pkg-file
	       Display information only for the package file pkg-name.

     -i, --case-insensitive
	       Make  the  standard  or	regular expression (-x) matching against
	       pkg-name in pattern case insensitive.

     -g, --glob
	       Treat <pattern> as a glob pattern.

     -x, --regex
	       Treat <pattern> as a regular expression according to the "modern"
	       or "extended" syntax of re_format(7).

QUERY FORMAT
     There are two types of keywords for the query format: the multiline and the
     normal one.  Only one type of multiline pattern is  accepted  for	a  given
     query.

   Normal patterns
     %n  Name of the matched package

     %v  Version of the matched package

     %o  Origin of the matched package

     %p  Prefix of the matched package

     %m  Maintainer of the matched package

     %c  Comment of the matched package

     %e  Description of the matched package

     %w  Home page of the matched package

     %V  Returns 0 if the package is not marked as "vital", and 1 if the package
	 is marked "vital".

     %l  License  logic  of the matched package - nothing for single, & for AND,
	 and | for OR

     %s[bh]
	 The flat size of the matched package, where b is in bytes, and h is  in
	 human readable format.

     %a  Returns  1  if the matched package was automatically installed as a de-
	 pendency of another package, 0 otherwise.  The package can be automati-
	 cally removed via `pkg autoremove' when this flag is set and  no  other
	 package depends on it.

     %Q  Alternative architecture of the matched package

     %q  Architecture of the matched package

     %k  Returns  1  if  the  matched  package is locked against modification or
	 deletion, 0 otherwise

     %M  message contained in the matched package

     %t  Timestamp that the package was installed

     %R  The name of the repository from which	the  package  was  installed  if
	 available, or "unknown-repository" otherwise.

     %X  Internal package checksum

     %?[drCFODLUGBbAyY]
	 Returns  0  if  the  list is empty and 1 if the list has information to
	 display.

	 d	 for dependencies

	 r	 for reverse dependencies

	 C	 for categories

	 F	 for files

	 O	 for options

	 D	 for directories

	 L	 for licenses

	 U	 for users

	 G	 for groups

	 B	 for required shared libraries

	 b	 for provided shared libraries

	 y	 for provides

	 Y	 for requires

	 A	 for annotations

     %#[drCFODLUGBbAyY]
	 Returns the number of elements in the list

	 d	 for dependencies

	 r	 for reverse dependencies

	 C	 for categories

	 F	 for files

	 O	 for options

	 D	 for directories

	 L	 for licenses

	 U	 for users

	 G	 for groups

	 B	 for required shared libraries

	 b	 for provided shared libraries

	 y	 for provides

	 Y	 for requires

	 A	 for annotations

   Multiline patterns
     %d[nov]
	 Expands to the list of dependencies for the matched  package,	where  n
	 stands  for  the  package name, o for the package origin, and v for the
	 package version.

     %r[nov]
	 Expands to the list of reverse dependencies for  the  matched	package,
	 where	n  stands  for the package name, o for the package origin, and v
	 for the package version.

     %C  Expands to the list of categories the matched package belongs to.

     %F[psugmftl]
	 Expands to the list of files of the matched package, where p stands for
	 path, s for checksum, u for owner, g for group,  m  for  mode	(permis-
	 sions),  f  for file flags, l for last modification time, and t for the
	 symlink target (or empty string if no symlink).

     %D  Expands to the list of directories of the matched package.

     %S[pugmf]
	 Expands to the list of (sub-)directories of the matched package,  where
	 p  stands for path, u for owner, g for group, m for mode (permissions),
	 and f for file flags. Same as %D but allows specifying suboptions.

     %O[kv]
	 Expands to the list of options of the matched package, where  k  stands
	 for option key and v for option value.

     %L  Expands to the list of license(s) for the matched package.

     %U  Expands to the list of users needed by the matched package.

     %G  Expands to the list of groups needed by the matched package.

     %B  Expands  to  the  list  of  shared  libraries used by programs from the
	 matched package.

     %b  Expands to the list of shared libraries provided by the  matched  pack-
	 age.

     %y  Expands to the list of provides for the matched package.

     %Y  Expands to the list of requires for the matched package.

     %A[tv]
	 Expands  to  the  list  of annotations for the matched package, where t
	 stands for the annotation tag, and v stands for the annotation value.

   Inline iteration with %{...%}
     When the format string contains a %{...%} construct, the entire  format  is
     interpreted  using  pkg_printf(3)	format codes instead of the legacy query
     format codes.  This allows multiline items to be joined on  a  single  line
     using a custom separator, rather than producing one line per item.

     The syntax is:

	   %X%{<item-format>%|<separator>%}

     Where  X  is a list-valued format code (A, B, C, D, F, G, L, O, U, d, r, b,
     y,  Y),  <item-format>  is  the  format  for  each  item,	and  <separator>
     (delimited by %|) is optional and inserted between items.

     Inside  %{...%},  use  pkg_printf(3)  sub-option codes: %On for option name
     (%Ok is accepted as a deprecated alias), %Ov for option value, %An for  an-
     notation  name  (%At is accepted as a deprecated alias), %Fn for file path,
     %Fp for file permissions, %Cn for category name,  etc.   See  pkg_printf(3)
     for the full list of format codes.

     Note:  When  using  %{...%},  the format codes outside the braces must also
     follow pkg_printf(3) conventions.	In particular, %Fn is used for file path
     (not %Fp as in legacy query format).

EVALUATION FORMAT
     Packages can be selected by using expressions comparing Variables (see  be-
     low)  to  string or integer values.  The mode of comparison is specified by
     the Operator (also listed below).	Expressions can  be  combined  using  &&
     (for  and)  and  ||  (for or).  Parentheses can be used for grouping in the
     usual manner.

     String values are either any text not containing whitespace (possibly  fol-
     lowed  by	but  not including whitespace) or any text enclosed in single or
     double quotes.

   Normal Variables
     %n  Name of the package (type string)

     %o  Origin of the package (type string)

     %p  Prefix of the package (type string)

     %m  Maintainer of the package (type string)

     %c  Comment of the package (type string)

     %e  Description of the package (type string)

     %w  WWW address of the package (type string)

     %s  Flatsize of the package (type integer)

     %a  Automatic status of the package (type integer)

     %q  Architecture of the package (type string)

     %k  Locking status of the package (type integer)

     %M  Message of the package (type string)

     %t  Timestamp that the package was installed (type integer)

     %i  Additional information about the package (type string)

     %#[drCFODLUGBbAyY]
	 Number of elements in the list of information (type integer).	 See  %?
	 above for what information is used.

   Multiline variables
     When used in an evaluation, these variables refer to the items in the list.
     The  condition evaluates to true if any element in the list matches.  Nega-
     tive operators are an exception: they check for the absence of any matching
     element.

     For example, "%dn != 'curl'" means "the package does not depend on curl".

     %d[nov]
	 Dependency of the package (type string)

     %r[nov]
	 Reverse dependency of the package (type string)

     %C  Category of the package (type string)

     %L  License of the package (type string)

     %B  Required shared library of the package (type string)

     %b  Provided shared library of the package (type string)

     %y  Provide of the package (type string)

     %Y  Require of the package (type string)

     %A[tv]
	 Annotation of the package (type string)

   Operators
     var ~ glob
	 The string value of var matches the given glob pattern.

     var !~ glob
	 The string value of var does not match the given glob pattern.

     var >[=] num
	 The numerical value of var is greater than [or equal to] the given num-
	 ber.

     var <[=] num
	 The numerical value of var is less than [or equal to] the given number.

     var =[=] [num | string]
	 The value of var is equal to the given number or string.

     var =~ [num | string]
	 The value of var is equal (case insensitive) to  the  given  number  or
	 string.

     var != [num | string]
	 The value of var is not equal to the given number or string.

     var !=~ [num | string]
	 The  value  of var is not equal case insensitive to the given number or
	 string.

ENVIRONMENT
     The following environment variables affect the execution of pkg query.  See
     pkg.conf(5) for further description.

     PKG_DBDIR

     CASE_SENSITIVE_MATCH

FILES
     See pkg.conf(5).

EXIT STATUS
     The pkg query utility exits 0 on success, and >0 if an error occurs.

EXAMPLES
     List all installed packages by name-version:
	   $ pkg query %n-%v

     List all dependencies for a package by origin:
	   $ pkg query %do subversion

     List all dependencies by package name-version:
	   $ pkg query %dn-%dv subversion

     List all reverse dependencies for a package:
	   $ pkg query %ro perl

     List all files and their known checksums for a package:
	   $ pkg query '%Fp %Fs' perl

     List all files for all packages:
	   $ pkg query '%o: %Fp'

     List all packages with no reverse dependencies:
	   $ pkg query -e '%#r = 0' %o

     List non-automatic packages:
	   $ pkg query -e '%a = 0' %o

     List automatic packages:
	   $ pkg query -e '%a = 1' %o

     List unmaintained packages:
	   $ pkg query -e '%m = ports@FreeBSD.org' %o

     List packages that depend on python312:
	   $ pkg query -e '%dn = python312' %o

     List all categories of a package on a single line, separated by spaces:
	   $ pkg query '%n: %C%{%Cn%| %}' firefox

     List all shared libraries used by a package on a single line:
	   $ pkg query '%n: %B%{%Bn%| %}' perl

     List all options of a package in key=value format:
	   $ pkg query '%n %O%{%On=%Ov%| %}' vim

SEE ALSO
     pkg_checksum(3), pkg_create(3), pkg_printf(3), pkg_repo_create(3),  pkg_re-
     pos(3),   pkg-keywords(5),   pkg-lua-script(5),   pkg-repository(5),   pkg-
     script(5), pkg-triggers(5), pkg.conf(5), pkg(8), pkg-add(8),  pkg-alias(8),
     pkg-annotate(8),  pkg-audit(8), pkg-autoremove(8), pkg-check(8), pkg-check-
     sum(8), pkg-clean(8),  pkg-config(8),  pkg-create(8),  pkg-delete(8),  pkg-
     fetch(8),	 pkg-help(8),	pkg-info(8),  pkg-install(8),  pkg-key(8),  pkg-
     lock(8), pkg-plugins(8), pkg-register(8), pkg-repo(8), pkg-repositories(8),
     pkg-rquery(8), pkg-rwhich(8), pkg-search(8), pkg-set(8), pkg-shell(8), pkg-
     shlib(8),	pkg-ssh(8),  pkg-stats(8),  pkg-triggers(8),  pkg-unregister(8),
     pkg-update(8),   pkg-updating(8),	 pkg-upgrade(8),   pkg-version(8),  pkg-
     which(8)

FreeBSD ports 15.quarterly	 April 17, 2026 		    PKG-QUERY(8)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=pkg-query&manpath=FreeBSD+15.1-RELEASE+and+Ports.quarterly>

home | help