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
Post a Comment