How to grep for the exact word if the string has got dot in it

前端 未结 4 1443
不思量自难忘°
不思量自难忘° 2021-02-14 03:52

I was trying to search for a particular word BML.I in a current directory.

When I tried with the below command:

grep -l  \"BML.I\" *
         


        
4条回答
  •  Happy的楠姐
    2021-02-14 04:34

    try grep -wF

    from man page:

     -w, --word-regexp
                      Select  only  those  lines containing matches that form whole words.  The
                      test is that the matching substring must either be at  the  beginning  of
                      the line, or preceded by a non-word constituent character.  Similarly, it
                      must be either at  the  end  of  the  line  or  followed  by  a  non-word
                      constituent  character.  Word-constituent characters are letters, digits,
                      and the underscore.
    
    
    
     -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.)
    

提交回复
热议问题