我試圖符合使用GAWK以下表達式模式:呆子正則表達式模式
static char *nm = "This is a test with many characters like [email protected]#^&";
的模式如下:
1. Line starts with static
2. 0 or more number of characters including whitespaces
3. char
4. 0 or more number of characters including whitespaces
5. =
6. 0 or more number of characters including whitespaces
7. "
8. 0 or more number of characters including whitespaces
9. "
10. 0 or more number of characters including whitespaces
11. ;
我試圖用gawk /^static.*char.*=.*\",*\";"/{print}
我我試圖在第一個匹配模式之後插入包含「bbbbb」的行,嘗試如下:
gawk '1; $1==nm1 && ++a==1 {print nm2}' nm1="^static.*char.*=.*\",*\";" nm2="bbbbb" "aa"
如果存在另一個靜態字符* nm =「這是一個包含許多字符(如$ @#^ &」)的測試;這將保持原樣。
請幫忙。
什麼是'&'了。
您可以使用此awk命令?你也可以用''*'替代引號附近的'。*',最後還有一個額外的引號。嘗試'gawk'/ ^static.*char。* =。*「。*」。*;/{print}'' – 123
嘗試:'/ ^static.*char.*=.*"[^"]*「 ;/{print}' – anubhava
@anubhava編輯了我的Q,並且要求在匹配的模式之後插入一個模式 –