鑑於以下命令:AWK域分隔 []
cat 11 | awk -F"[\[\]]" '{print $1,$2}'
cat 11 | awk -F"[\]\[]" '{print $1,$2}'
爲什麼AWK輸出不同勢:
[email protected]:~/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.
[email protected]:~/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
[email protected]:~/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.
請修改您的帖子以包含您的預期輸出。或者指出每個輸出塊有什麼問題。爲了我的理解你的問題,第一個結果塊看起來不錯。祝你好運。 – shellter
你使用的是什麼版本的'awk'?我的輸出和你的貓11一樣awk -F「[\] \ []」'{print $ 1,$ 2}''這兩種方法。 –