xugrep1

Gabriel Weaver edited this page Jun 2, 2013 · 2 revisions
Clone this wiki locally

NAME

xugrep - Extract strings in the language of grammar production

SYNOPSIS

xugrep xupath file ...

DESCRIPTION

xugrep(1) generalizes grep(1); xugrep(1) extracts all strings that match an XUPath from one or more files.

Traditional grep(1) extracts all lines in a file that contain strings in the language of a regular expression. grep(1) outputs a sequence of strings that match a regular expression with some amount of surrounding context expressed in lines. The positions of those strings are line numbers.

xugrep(1) generalizes that class of languages that we can practically extract on the UNIX command line from regular to context-free.

The xupath specifies that language of the strings to extract.

All files are processed in the order specified.

OPTIONS

The current version of xugrep(1) does not have any options.

FILES

ENVIRONMENT

DIAGNOSTICS

Currently there are no error codes. In future releases, however, we will be thinking more carefully about error codes and how to report these errors back to the calling environment.

BUGS

There are likely plenty as this release of xugrep(1) incorporates a new API for text corpora. Bug reports are welcomed, we want to make these tools as strong as possible.

EXAMPLES

Cisco IOS

  • xugrep "/builtin:file/ios:interface" ./data/test/cisco_ios/router.v1.example ./data/test/cisco_ios/router.v2.example | sort -k 1. Extract all Cisco IOS interface blocks from within both files. Sort the results by the file from which the interfaces were extracted.
  • xugrep "/builtin:file/ios:interface/builtin:line" ./data/test/cisco_ios/router.v1.example | sort -k 3 | sort -k 2 | sort -k 1. Extract the lines per interface within the Cisco IOS router configuration file. Sort the results by line number, then by interface, then by the file from which they were extracted.
  • xugrep "/builtin:file/ios:interface/builtin:line[re:testsubtree('access-group','e')]" ./data/test/cisco_ios/router.v1.example | sort -k 3 | sort -k 2 | sort -k 1. Extract the lines per interface within the Cisco IOS router configuration file that contain a reference to the term 'access-group'. Sort the results by line number, then by interface name, then by the file from which they were extracted.

TEI XML

  • xugrep "/builtin:file/tei:section" ./data/test/tei_xml/section.tei.v1.xml. Extract the sections within this security policy encoded in TEI XML.
  • xugrep "/builtin:file/tei:section/tei:subsection" ./data/test/tei_xml/section.tei.v1.xml. Extract the subsections and report them relative to section and file names.
  • xugrep "/tei:subsubsection" ./data/test/tei_xml/section.tei.v1.xml. Extract the subsubsections from the TEI XML security policy.
  • xugrep "/tei:subsubsection[re:testsubtree('Globus','e')]" ./data/test/tei_xml/section.tei.v1.xml. Extract the subsubsections that contain the term 'Globus' from the TEI-XML security policy.

AUTHOR

Gabriel A. Weaver

SEE ALSO

grep(1), xudiff(1), xupath(1), xuwc(1).


Creative Commons License
XUTools Wiki by Gabriel A. Weaver is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.