I need to work with records having #AX in the EXP1 , please see my data sample and my attempt below:
$ cat xx
08:30:33 KEY1 (1255) EXP1 [#AX0010X001] VAL:20AX0030006
08:30:33 KEY1 (1255) EXP1 [#0200000001] VAL:20AX0030006
08:30:33 KEY1 (1255) EXP1 [#AX0020X002] VAL:20AW0030006
08:30:33 KEY1 (1255) EXP1 [#A02210X001] VAL:20AW0030006
$ gawk '{ if($0 ~ "\[#AX") print; }' xx
gawk: cmd. line:1: warning: escape sequence `\[' treated as plain `['
gawk: cmd. line:1: (FILENAME=xx FNR=1) fatal: Unmatched [ or [^: /[#AX/
I tied other way specify left bracket an it worked:
gawk '{ if($0 ~ "[[]#AX") print; }' xx
08:30:33 KEY1 (1255) EXP1 [#AX0010X001] VAL:20AX0030006
08:30:33 KEY1 (1255) EXP1 [#AX0020X002] VAL:20AW0030006
I tried awk, nawk and gawk, same results, although gawk is more helpful in spelling out which file and line caused the problem when I used '\[' escape sequence.
My question is why awk dies? and why gawk shows this warning about '\[' treated as plain '['?
Thanks in advance.