PKG_GREP_SUMMARY(1)

NAME
pkg_grep_summary - tool for grepping pkgsrc summary file

SYNOPSIS
pkg_grep_summary -h
pkg_grep_summary [option] field awk_expression
pkg_grep_summary [option] -e field
pkg_grep_summary [option] -m field regexp
pkg_grep_summary [option] -s field string
pkg_grep_summary [option] -S field filename
pkg_grep_summary [option] -t strategy field condition
pkg_grep_summary -T

DESCRIPTION
pkg_grep_summary takes package summaries on stdin and outputs those matching the specified condition. Format of summary is described in pkg_summary(5). Fields are PKGPATH, PKGNAME, DEPENDS, MAINTAINER and so on, actually anything separated by = sign. In addition to fields really present on input a few artificial fields are supported: PKGBASE, PKGPATHe, PKGPAIR, PKGPABA and PKGPANA. PKGBASE is a PKGNAME with package version stripped. PKGPATHe (enriched PKGPATH) is PKGPATH with ASSIGNMENTS (if present) separated by colon symbol, for example, lang/py-psyco:PYTHON_VERSION_REQD=25. PKGPAIR is a PKGPATH and PKGBASE separated by comma character, for example, net/dhisd,dhisd. PKGPABA is a synonym for PKGPAIR. PKGPANA is a PKGPATH and PKGNAME separated by comma, for example textproc/dict-server,dict-server-1.11.2. pkg_grep_summary is a search tool somewhat similar to grep(1), PKGSRCDIR/pkglocate, pkgfind and others. Unlike grep(1) it uses summary information about one package instead of line of text as an indivisible block of text. Unlike pkgfind and PKGSRCDIR/pkglocate it doesn't scan pkgsrc source tree. For scanning pkgsrc source tree you may use pkg_src_summary(1) or pkg_micro_src_summary(1). The following variables can be used in awk_expression: "fname" (field name to check), "fvalue" (part of line after = sign) and associative array "fields" mapping field names to values which is available only if field is `.' (single dot).

OPTIONS

-h  display help message.

-i  ignore case. Before matching field is converted to lower case.

-v  invert the sense of match

-r  exit status is 1 if no matches were found.

-R  option -r is implied and "No matches found" is output to stderr.

-f fields
    a list of fields to output, by default the whole package summary is output.

-e field
    outputs summaries in which field is either empty or absent.

-m field regexp
    outputs summary if regexp matches field

-s field string
    outputs summary if field is equal to string

-S field filename
    reads strings from filename, one string per line, and outputs summary given on stdin if field is equal to one of read strings.

-t strategy field condition
    outputs summary if condition matches field according to search strategy strategy. Available search strategies are: exact, prefix, suffix, substring, word, first, last, re, strfile, strlist, awk, kw (keywords) and empty. Search strategy re is for matching using regexp (ERE). Search strategies first, last and word are for matching first, last or any separate word within field. With kw (keywords) condition is treated as a list of words each of which should present in field. With search strategy strlist, condition is treated as a list of words at least one of which should present in field.

-T  display all search strategies available for -t and exits. Doubled -T will show search strategies with their descriptions separated by TAB character.

NOTES
-t exact <field> <string> and -s <field> <string> are equivalents
-t re <field> <regexp> and -m <field> <regexp> are equivalents
-t strfile <field> <filename> and -S <field> <filename> are equivalents
-t awk <field> <awk_expr> and <field> <awk_expr> are equivalents
-t empty <field> '' and -e <field> are equivalents

EXIT STATUS
If unexpected failure happened, an exit status is more than 1. If matches were not found and option -r or -R were applied, exit status is 1. Otherwise, exit status is 0.

EXAMPLES
pkg_grep_summary -s PKGPATH 'devel/libjudy' pkg_grep_summary -m PKGPATH '^wip/' pkg_info -Xa | pkg_grep_summary SIZE_PKG 'fvalue+0 > 100000000' pkg_grep_summary PKGNAME 'fvalue ~ /judy/' \
      < /usr/pkgsrc/packages/pkg_summary.txt pkg_grep_summary PKGPATH 'fvalue ~ /^lang\//' \
      < /usr/pkgsrc/packages/pkg_summary.txt pkg_grep_summary DEPENDS 'fvalue ~ /libX11/' \
      < /usr/pkgsrc/pkg_src_summary.txt pkg_grep_summary COMMENT 'toupper(fvalue) ~ /DNS/' \
      < /usr/pkgsrc/pkg_src_summary.txt pkg_info -QPKGPATH -a > /tmp/wanted_pkgpaths.txt pkg_grep_summary -S PKGPATH /tmp/wanted_pkgpaths.txt \
      < /usr/pkgsrc/packages/pkg_summary.txt pkg_grep_summary -t word COMMENT DNS \
      < /usr/pkgsrc/pkg_src_summary.txt pkg_bin_summary -f PKGNAME,automatic,REQUIREDBY | pkg_grep_summary . 'fields ["automatic"] == "yes" &&
                    fields ["REQUIREDBY"] == ""' pkg_grep_summary -i -t kw COMMENT 'dns server' \
      < /usr/pkgsrc/packages/pkg_summary.txt pkg_grep_summary -t strlist MAINAINER 'cheusov@tut.by vle@gmx.net' \
      < /usr/pkgsrc/packages/pkg_summary.txt

SEE ALSO
pkg_summary-utils(7), pkg_summary(5) pkg_src_summary(1) pkg_micro_src_summary(1) pkg_info(1)

AUTHOR
Aleksey Cheusov <vle@gmx.net>