且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在不转义的情况下grep星号?

更新时间:2022-06-08 22:21:50

使用标记 -F 搜索固定字符串-而不是正则表达式。从 man grep

Use the flag -F to search for fixed strings -- instead of regular expressions. From man grep:

   -F, --fixed-strings
          Interpret  PATTERN  as  a  list  of  fixed strings, separated by
          newlines, any of which is to be matched.  (-F  is  specified  by
          POSIX.)

例如:

$ grep -F "ab*c" <<< "ab*c"
ab*c