Hello,
My input would be :
###Anything
int b,c,a;
int a,b,b;
###Anything
int c,d,c;
int k,l;
###ANYTHING
Many declarations interspersed with other statements. I am trying to find only the declarations where a line has a variable declared more than once.
The output for the above would be:
int a,b,b;
int c,d,c;
I did grep '^[ ]int[ ]*[a-z][a-z0-9]*\(,[a-z][a-z0-9]\)\{0,\};$' to match all declarations, but I am not able to make the regex remember a variable and match it when it occurs later. My output just catches all the declaration statements.
Please help.
Thanks,
Prasanna
---------- Post updated at 12:55 PM ---------- Previous update was at 12:51 PM ----------
To add, I am only using grep to do this. I have done this before, but I don't remember. I am sure it's possible with grep with a little tweak to the regex and the backreferencing.