Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试为 mac 上的 bash shell 获取不区分大小写的单词匹配。
我尝试:
echo "one Word" | grep -e "\bword\b/i"
和
echo "one Word" | grep -e "(?i)\bword\b"
但没有运气。有任何想法吗?
grep的-i选项用于忽略大小写:
-i
echo "one Word" | grep -i "\bword\b"
你正在尝试做的事情看起来很糟糕。使用 GNU grep,您可以这样做:
echo "one Word" | grep -P "(?i)\bword\b"
...尽管显然-i开关是执行此操作的标准方法。