countclassesmatching

Table of Contents

Prototype: countclassesmatching(regex)

Return type: int

Description: Count the number of defined classes matching regex.

This function matches classes, using an anchored regular expression that should match the whole line. The function returns the number of classes matched.

Arguments:

  • regex: regular expression, in the range: .*

Example:

body common control
{
      bundlesequence => { "example" };
}

bundle agent example
{
  vars:
      # this is anchored, so you need .* to match multiple things
      "num" int => countclassesmatching("cfengine");

  reports:
      "Found $(num) classes matching";
}

Output:

R: Found 1 classes matching