linux - egrep regex operation not working as expected -


i have file content such:

[text_id=2] [text_rev=3] [no_of_bytes=16] 0010002$%!003000040000000010100 [txt] ff ff [txt_id=2$@] [txt_rev=3] [no_of_bytes=17] 0010002003000040000000010100  [txt]  ff ff $%^& 

i want identify other 0-9, a-z, a-z, space, enter , tab junk character.

i have make sure = or [ or ] when comes part of [context=val] line, valid character. if comes in other line junk character.

for example in 9th line of file if comes =, [ or ], junk:

0010002003000040000000010100=[ 

so i'm using below:

egrep -v "^[' '0-9a-za-z\t\n\v\f\r]*$|^[ ]*\[[a-z].*\_*[a-z]*=*[0-9]*\][ ]*$" sspr.240, gives output as:  0010002$%!003000040000000010100 $%^& 

however not considering line:

[txt_id=2$@] 

how can modify egrep statement?

you can try like:

 egrep -v '^([[:space:]]*\[[[:alnum:]_]+=?[[:alnum:]_]*][[:space:]]*|[[:alnum:][:space:]_]*)$' file 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -