Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation
 

Related Documentation

 

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.

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 with 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

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

Starting with 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 [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, /.

pattern

(Mandatory) Regular expression.

Usage Examples

Example: Searching Files Using an Op Script

 

Related Documentation

 

Published: 2012-11-05

 

Related Documentation

 

Published: 2012-11-05