ON THIS PAGE
jcs:grep Template
XSLT Syntax
<xsl:call-template name="jcs:grep"> <xsl:with-param name="filename" select="filename"/> <xsl:with-param name="pattern" select="pattern"/> </xsl:call-template>
SLAX Syntax
call jcs:grep($filename=filename, $pattern=pattern);
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 pattern is matched to each line of the file. The template does not support matching a pattern spanning multiple lines.
The jcs:grep
template supports
a maximum input file size of 9.5MB. 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.
<match> { <input> <output> }
Starting in Junos OS Release 11.1, if an absolute path is not
specified for the input file, the default path is relative to the
user’s home directory for op scripts, and it is relative to
the /var/tmp/ directory for commit
scripts and for event scripts that are enabled at the [edit event-options
event-script]
hierarchy level. For event scripts that are enabled
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. Starting in Junos OS Release 11.1, if you do not specify an
absolute path, the path is relative to the user’s home directory
for op scripts, and it is relative to the /var/tmp/ directory for commit scripts and for event scripts that are enabled
at the |
pattern |
Regular expression to match in the file. |