Table of Contents
countlinesmatching
Table of Contents
Prototype: countlinesmatching(regex, filename)
Return type: int
Description: Count the number of lines in file filename
matching
regex
.
This function matches lines in the named file, using an anchored regular expression that should match the whole line, and returns the number of lines matched.
Arguments:
regex
: regular expression, in the range:.*
filename
:string
, in the range:"?(/.*)
Example:
body common control
{
bundlesequence => { "example" };
}
bundle agent example
{
vars:
# typically there is only one root user
"no" int => countlinesmatching("root:.*","/etc/passwd");
reports:
"Found $(no) lines matching";
}
Output:
R: Found 1 lines matching