I am trying to get a case insensitive word match for a bash shell on a mac.
I try:
echo "one Word" | grep -e "\bword\b/i"
and
echo "one Word" | grep -e "(?i)\bword\b"
But no luck. Any ideas?
grep的-i
选项用于忽略大小写:
echo "one Word" | grep -i "\bword\b"
What you are trying to do looks perlish. With GNU grep, you can do this:
echo "one Word" | grep -P "(?i)\\bword\\b"
...although clearly the -i
switch is the standard way to do this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.