I have a file lets say temp.log with the following contents-blahblah SomeOtherClassName blahblahblahblahblah MyClassName blah blah blah userId:[6729223726254951za],key:[09809890980980908d0e6],token:[0238234234-3948-4d9],SessionScope:[0238234234-3948-4d9],PageScope:[0238234234-3948-4d9],RequestScope:[0238234234-3948-4d9], requestUrl:/blah/blah/blahblahblah SomeOtherClassName blahblahblahblahblah MyClassName blah blah blah userId:[6729223726254951za],key:[09809890980980908d0e6],token:[0238234234-3948-4d9],SessionScope:[1111111-3948-4d9],PageScope:[0238234234-3948-4d9],RequestScope:[0238234234-3948-4d9], requestUrl:/blah/blah/blahI want to parse the log file and output if the log line which have MyClassName and if one of the sessionscope, pagescope or requestscope value does not match the token value. For example in my example line 2 and 4 have MyClassName and within the two line 4 has a SessionScope value different than token so line 4 should be output. I am struggling with the grep and backreference options.
grep a certain pattern in a line in a file and output the line if match found in the same line
text processing;grep;regular expression
Capture the token into a group and then test it using backreferences:$ grep 'MyClassName' log |   grep -vE 'token:(\[[[:xdigit:]-]+\]),SessionScope:\1,PageScope:\1,RequestScope:\1'blahblah MyClassName blah blah blah userId:[6729223726254951za],key:[09809890980980908d0e6],token:[0238234234-3948-4d9],SessionScope:[1111111-3948-4d9],PageScope:[0238234234-3948-4d9],RequestScope:[0238234234-3948-4d9], requestUrl:/blah/blah/blah