I would like to write a regex using unix command that identifies all strings that do not confirm to the following format
First Leter is UpperCase
Followed by any number of letters
Underscore
Followed by UpperCase Letter
Followed by any number of letters
Underscore
and so on .............
The number of underscores is variable
So valid ones are Invalid ones are
Alpha_Beta_Gamma alph_Beta_Gamma
Alpha_Beta_Gamma_Delta Alpha_beta_Gamma
Alppha_Beta Alpha_beta
Aliph_Theta_Pi_Chi_Ming Alpha_theta_Pi_Chi_Ming
grephas a-voption which inverts the match (ie. returns non-matching lines). The-Eoption puts grep intoextended-regexpmode (which allows for+and parentheses to be unescaped in the pattern).The pattern you can use is (broken up for clarity):
So assuming you have a file
test.datthat contains your 8 strings from your question:Returns: