mac find -name *.png no funciona

mac find -name *.png no funciona

Estoy intentando buscar recursivamente un nombre de archivo que termine en .png. Mi comando de búsqueda funciona bien para *.js, pero no para *.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 

Respuesta1

Probablemente tenga un .pngarchivo en su directorio actual y *su shell lo expanda.

Aquí tienes una explicación práctica. Cree un directorio llamado test, luego otro llamado subdentro de él y finalmente un archivo myfile.txtllamado sub. Luego cden test. Aquí hay comandos para hacer eso:

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

Puede ejecutar findy obtendrá los resultados esperados:

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

Ahora cree un archivo llamado cause.txty testejecútelo findnuevamente:

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

Esta vez no se encuentra nada porque Shell expande *y su findcomando se convierte en:

~/test >find sub -name cause.txt

No hay ningún cause.txtarchivo en sub, por lo que no hay resultados.

Para evitar este problema hay que evitar el asterisco con una barra invertida:

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

información relacionada