grep은 --include를 무시하는 것 같습니다.

grep은 --include를 무시하는 것 같습니다.

man grep설명하다

grep [OPTIONS] PATTERN [FILE...]

. . .

   --include=GLOB
          Search  only  files whose base name matches GLOB (using wildcard
          matching as described under --exclude).

그래서 나는 들어갔다.

grep --include="*.html" 'li' *

li현재 디렉토리에서 HTML 파일의 인스턴스를 검색합니다. 대신 liHTML이 아닌 파일에서도 디렉토리의 모든 사용 목록을 얻습니다 . 내가 뭘 잘못했나요? 나는 다음과 같은 다양한 변형을 시도했습니다.

grep --include=\*.html 'li' *

하지만 행운은 없습니다.

ベストアンサー1

--include=PATTERN추가하는 경우에만 작동합니다.-r

$ grep -r --include='*.html' 'li' .

-R, -r, --recursive   Read all files under each directory, recursively; this is equivalent to the -d recurse option.
--include=PATTERN     Recurse in directories only searching file matching PATTERN.
--exclude=PATTERN     Recurse in directories skip file matching PATTERN.

おすすめ記事