给定以下命令:
cat 11 | awk -F"[\[\]]" '{print $1,$2}'
cat 11 | awk -F"[\]\[]" '{print $1,$2}'
为什么awk输出不同:
zxscgdb@linux:~/tmp> cat 11
12-05 09:07:53:33 F[zxinit_lib.c] L[485] E[10106] process:zxsc_gdb is ok.
12-05 09:08:03:35 F[zxinit_lib.c] L[485] E[10106] process:zxsc_gdb is ok.
12-05 09:08:13:37 F[zxinit_lib.c] L[485] E[10106] process:zxsc_gdb is ok.
zxscgdb@linux:~/tmp> cat 11 | awk -F"[\]\[]" '{print $1,$2}'
awk: warning: escape sequence `\]' treated as plain `]'
awk: warning: escape sequence `\[' treated as plain `['
12-05 09:07:53:33 F zxinit_lib.c
12-05 09:08:03:35 F zxinit_lib.c
12-05 09:08:13:37 F zxinit_lib.c
zxscgdb@linux:~/tmp> cat 11 | awk -F"[\[\]]" '{print $1,$2}'
awk: warning: escape sequence `\[' treated as plain `['
awk: warning: escape sequence `\]' treated as plain `]'
12-05 09:07:53:33 F[zxinit_lib.c] L[485] E[10106] process:zxsc_gdb is ok.
12-05 09:08:03:35 F[zxinit_lib.c] L[485] E[10106] process:zxsc_gdb is ok.
12-05 09:08:13:37 F[zxinit_lib.c] L[485] E[10106] process:zxsc_gdb is ok.