我試圖搜索當前目錄中的特定單詞BML.I
。如果字符串已經有點,grep的確切單詞
當我用下面的命令嘗試:
grep -l "BML.I" *
它顯示了所有的結果,如果它包含單詞BML
是否有可能到grep的精確匹配BML.I
我試圖搜索當前目錄中的特定單詞BML.I
。如果字符串已經有點,grep的確切單詞
當我用下面的命令嘗試:
grep -l "BML.I" *
它顯示了所有的結果,如果它包含單詞BML
是否有可能到grep的精確匹配BML.I
嘗試grep -wF
從手冊頁:
-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.)
我使用fgrep
,與grep -F
相同
您是否在尋找文件名或文件內容? – Alepac 2013-03-20 11:02:40
@Alepac顯然他在尋找內容。 – Kent 2013-03-20 11:10:20
只讀'man grep'。 – 2013-03-20 11:11:56