bash - Printing lines in which atleast one assignment operator(=) even if a conditional operator(==) exits in that line -


in unix scripting

i have file has lines follows:

if(a==b || b=c && c==d) if(a!=b) if(a=b) 

i have print lines having assignment operator i.e

if(a==b || b=c && c==d) , if(a=b) 

anybody pls help


so you're looking (simplistically) = on own, no other = abutting it. can done regex [^=]=[^=] (an = other = on both sides).

unfortunately, capture things != or >= may want expand bit. start:

grep '[^!<>=]=[^=]' inputfile 

that should catch vast majority although you're in same boat want process xml regexes rather xml processor - there edge case don't because regex far simpler tool language parser. however, stated, should fine weirdest of edge cases.

and may still have handle cases (for example) = may @ start or end of line pretty unlikely since coder formatting code insane :-)


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -