Unix command to match a pattern
For example, let us suppose we have a following line:
RESULT: test=abc slave=def owners=own1,test,own2,newown time=32 status=fail
Here test, slave, owners, time and status are different properties. The
number of properties can vary, i.e., another property like category=xyz
can be present or some property might not be present.
I am looking for a regular expression that matches if "owners=" contains a
particular owner, say "own2". Also, this regulra expression should not
match other occurrences in the line. For example line cane be:
RESULT: test=own2 slave=def owners=own1,test,own2,newown time=32 status=fail
Regular expression should not match own2 for "test" property.
I spent hours searching but failed :(
I looked for regular expressions with egrep. I tried the following:
line="RESULT: test=abc slave=def owners=own1,test,own2,newown time=32
status=fail"
echo $line | egrep "owners=*own2*"
This failed to return any value. I am not getting what is wrong with my
regular expression.
I am looking for soemthing that works on all unix falvors like linux, aix,
solaris etc.
Any help is appreciated.
No comments:
Post a Comment