When building a custom UNIX check in Symantec Control Compliance Suite for Reporting and Analytics (CCS RA), what is the difference between the =~ operator and the %~ operator ?
Here are definitions and examples of how these operators function.
The =~ operator - An expression written using the =~ operator
will pass only when every value in the list on the left hand
side matches the regular expression on the right hand side.
In an example expression such as:
file contents =~ /^hello world/m
the check written using the =~ operator would have passed
in cases where the files content field in question had the string
"hello world" on every line and no other string other than
"hello world". For example the expression would pass if the
file contents field contained the following:
hello world
hello world
hello world
The file contents =~ /^hello world/m expression would fail
when the file contents field contains anything other than the
string “hello world”. An example of a file contents field that
would cause the expression to fail:
hello world
hello kitty
hello world
The %~ operator - An expression written using this operator
will pass when there is at least one occurrence of the pattern
in the file contents field.
In the example expression such as:
file contents %~ /^hello world/m
the check written using the %~ operator would pass
because the string hello world was present in the file
along with any other strings. For example, if the file
contents field contained the following, the expression
would pass:
Hello world
Hello kitty
Hello world
The file contents %~ /^hello world/m expression fails
when the pattern is not found in the list. An example of a
file contents field that would produce a failure would be:
Hello kitty
Hello universe