grep으로 온전히 일치하는 단어만 검색하기 질문
글쓴이: kkb / 작성시간: 목, 2021/08/26 - 8:53오후
vi에서 온전히 일치하는 단어만 검색하려면
/\<apple\>
위와 같이 검색하면 온전히 일치하는 단어만 검색되잖아요?
This is a apple juice. 검색되고
ret=apple(2, 3.14159); 검색되고
ice->juice->apple++; 검색되고
sum=pine+apple-2; 검색됩니다.
반면에,
apple_juice 검색되지 않고
applemango 검색되지 않고
2apple 검색되지 않죠.
/apple
위와 같이 검색해야 위의 모든 문장들이 검색되겠죠.
이처럼 grep에서도 온전히 일치하는 단어만 검색하는 방법이 있나요?
Forums:
아래와 같이 하면 되지 않을까요?[hyun@ ~]$
아래와 같이 하면 되지 않을까요?
똑같이 하면 되는데,, 왜 안해 보셨나요?
똑같이 하면 되는데,, 왜 안해 보셨나요?
답변 감사합니다
아 분명히 한번 해보고 안되길래 질문 올린 건데;;
이상하네요
죄송합니다
답변 주신 분들 모두 감사드립니다
$ man grep
$ man grep
-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.
댓글 달기