[英]mawk program does not understand word border markers : "\<", "\>"
我剛剛注意到 Ubuntu 默認沒有安裝gawk
的新安裝。
因此,我所有包含單詞邊框標記的 awk 表達式:"<", ">" 根本不起作用,例如:
$ readlink -e $(which awk)
/usr/bin/mawk
$ echo "word1 Bluetooth word3" | awk '/\<Bluetooth\>/'
$
有沒有辦法匹配同時適用於mawk
和gawk
單詞?
取決於你想用比賽做什么,但這可能就足夠了:
$ echo "word1 Bluetooth word3" | awk '/(^|[^[:alnum:]_])Bluetooth([^[:alnum:]_]|$)/'
word1 Bluetooth word3
在所有 awks 中,甚至僅在 POSIX awks 中,都沒有表示“單詞邊界”的通用轉義序列。
如果這不是您所需要的全部,那么編輯您的問題以更好地解釋您想對匹配字符串做什么,並提供演示該用法的示例輸入/輸出。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.