Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Automation Scripting User Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

jcs:grep Template

date_range 13-Jan-21

XSLT Syntax

content_copy zoom_out_map
<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

content_copy zoom_out_map
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.

Note:

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.

content_copy zoom_out_map
<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 [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

Regular expression to match in the file.

footer-navigation