xgrep(1)
NAME
xgrep - search content of an XML file
SYNOPSIS
xgrep [-h] [-v] [-p] [-c catalog-file] [-x xpath] [-s string] ... [-s string] [infile] [infile] ...
DESCRIPTION
xgrep provides facilities for searching content in XML files. The
search is specified either as an XPath via the -x flag, or a custom
syntax including extended regular expressions via the -s flag. Multiple input files may be specified; if none are provided, input is read
from stdin.
OPTIONS
xgrep accepts the following options:
- -x xpath
- An XPath specification of the elements of interest.
- -s string
- A custom string format specifying the elements of interest. The string format is base-element:element/regex/,element/regex/,... where base-element is the name of the elements within which a match should be attempted, the match succeeding if, for each element/regex/ pair, the content of an element of that name is matched by the corresponding regex. If multiple -s flags are specified, a match by any one of them is returned.
- -c catalog-file
- Use the specified catalog file instead of the default.
- -p Regular expressions use Perl syntax as implemented in the PCRE
- library. (This option only available when xgrep has been linked with the PCRE library.)
- -h Display usage information
- -v Display version information
EXAMPLES
- Consider an XML format, for personnel information, in which each person
element has descendant elements called name and hiredate. To find all
person elements with "Smith" in the content of the name element and
"2000" in the content of the hiredate element, do:
- xgrep -s 'person:name/Smith/,hiredate/2000/' a.xml b.xml
SEE ALSO
AUTHOR
- Brendt Wohlberg <software@wohlberg.net>