- 論壇徽章:
- 0
|
在使用awk進(jìn)行文本查找時(shí)發(fā)生以下錯(cuò)誤,請(qǐng)教大家如何處理,對(duì)于特殊字符[做了轉(zhuǎn)義無(wú)效,使用grep就可以
$ echo "[Section1]"|awk '{if($0 ~ "^\["){print $0}}'
awk: 0602-521 There is a regular expression error.
[] imbalance.
The source line number is 1.
The error context is
{if($0 ~ >>> "^\[") <<<
$ echo "[Section1]"|awk '{if(match($0,"^\[")>0){print $0}}'
awk: 0602-521 There is a regular expression error.
[] imbalance.
The source line number is 1.
The error context is
>>> {if(match($0,"^\[") <<<
$ echo "[Section1]"|grep "^\["
[Section1] |
|