현재 단어에서 특정 단어 BML.I
을 검색하려고했습니다.문자열에 점이있는 경우 정확한 단어를 grep하는 방법
나는 아래의 명령을 시도 : 그것은 BML
그것이 가능한 정확히 일치하는 grep으로하는 것입니다 단어가 포함되어있는 경우는 모든 결과를 표시
grep -l "BML.I" *
BML.I
현재 단어에서 특정 단어 BML.I
을 검색하려고했습니다.문자열에 점이있는 경우 정확한 단어를 grep하는 방법
나는 아래의 명령을 시도 : 그것은 BML
그것이 가능한 정확히 일치하는 grep으로하는 것입니다 단어가 포함되어있는 경우는 모든 결과를 표시
grep -l "BML.I" *
BML.I
당신 그 (것)들을 도주 할 필요가있다. (마침표)는 기본적으로 모든 문자와 일치하므로 -w를 지정하여 특정 단어와 일치시킵니다.
grep -w -l "BML\.I" *
위의 두 가지 이스케이프 레벨이 있습니다. 따옴표는 쉘이 BML\.I
을 grep에 전달하도록합니다. \
은 grep
의 기간을 이스케이프합니다. 당신이 따옴표를 생략 할 경우, 쉘은 기간의 탈출로 \
해석 (단순히 grep
에 이스케이프 기간 전달할 것)
사람 페이지에서 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
@Alepac 분명히 그는 콘텐츠를 찾고 있습니다. – Kent
'man grep'을 읽으십시오. –