mac find -name *.png가 작동하지 않습니다.

mac find -name *.png가 작동하지 않습니다.

.png로 끝나는 파일 이름을 재귀적으로 검색하려고 합니다. 내 find 명령은 *.js에서는 제대로 작동하지만 *.png에서는 작동하지 않습니다.

~ >find dev -name *.png
~ >find dev -name bluerightarrow.png
dev/sandbox/ScheduleEditorTS/ScheduleEditorTS/img/bluerightarrow.png
~ >find dev -name *.js
dev/backup/ScheduleEditorTS/packages/jQuery.2.1.3/Content/Scripts/jquery-2.1.3-vsdoc.js
dev/backup/ScheduleEditorTS/packages/jQuery.2.1.3/Content/Scripts/jquery-2.1.3.js
... etc 

답변1

아마도 .png현재 디렉토리에 파일이 있고 *쉘에 의해 확장되었을 것입니다.

다음은 실용적인 설명입니다. 라는 디렉토리를 만들고 그 안에 test또 다른 디렉토리를 만들고 sub마지막으로 .라는 파일을 myfile.txt만듭니다 sub. 그런 cd다음 test. 이를 수행하는 명령은 다음과 같습니다.

~ >mkdir -p test/sub
~ >touch test/sub/myfile.txt
~ >cd test

실행하면 find예상되는 결과를 얻을 수 있습니다.

~/test >find sub -name *.txt
sub/myfile.txt

cause.txt이제 호출 된 파일을 만들고 다시 test실행하십시오 find.

~/test >touch cause.txt
~/test >find sub -name *.txt

이번에는 쉘이 확장되고 *명령 find이 다음과 같기 때문에 아무것도 발견되지 않습니다.

~/test >find sub -name cause.txt

cause.txt에 파일이 없으므로 sub결과가 없습니다.

이 문제를 방지하려면 백슬래시를 사용하여 별표를 이스케이프 처리해야 합니다.

~/test >find sub -name \*.txt
sub/myfile.txt

관련 정보