Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

jcs:grep Template

XSLT Syntax

SLAX Syntax

Description

Search the given input file for all instances matching the specified regular expression and write the matching strings and corresponding lines to the result tree. The template matches the pattern to each line of the file. The template does not support matching a pattern spanning multiple lines.

Note:

The jcs:grep template supports a maximum input file size of 9.5 MB. If an input file exceeds this maximum, the script generates an error regarding xmlSAX2Characters: huge text node and Extra content at the end of the document.

If the regular expression contains a syntax error, the template generates an error for every line of the file. For each match, the template adds a <match> element, which contains <input> and <output> child tags, to the result tree. The template writes the matching string to the <output> element and writes the corresponding matching line to the <input> element.

If you specify a relative path for the input file, the script type determines the default path.

  • Op scripts—Default path is relative to the user’s home directory.

  • Commit scripts—Default path is relative to the /var/tmp/ directory.

  • Event scripts—Default path is relative to the /var/tmp/ directory for event scripts configured at the [edit event-options event-script] hierarchy level. For event scripts configured at the [edit system scripts] hierarchy level, the default path is relative to the top-level directory, /.

Parameters

filename

Absolute or relative path and filename of the file to search.

pattern

Regular expression to match in the file.