Mediante find podemos buscar mediante muchos parámetros o incluso ejecutar comandos para cada fichero con ciertas características. Hoy vamos a ver como buscar ficheros por tipo:
Para buscar por tipo deberemos usar la opción -type con los siguientes modificadores:
s: Permite buscar sockets, por ejemplo:
[BASH]# find /tmp/ -type s
/tmp/mysql.sock
/tmp/clamd.socket
d: Permite buscar directorios, por ejemplo:
[BASH]# find . -type d
.
./dynamic
./FileCache
./FileCache/__AUTO_PURGE__
./FileCache/__AUTO_PURGE__/1
./FileCache/__AUTO_PURGE__/1/9
./FileCache/__AUTO_PURGE__/1/9/6
f: Permite buscar solo ficheros, por ejemplo:
[BASH]# find . -type f
./stats.email.loop.stats_fe4e398820c7a02888dbbe4be4c2a6d0.stat
./lol
./banner.png
./logo.png
./lolme
./lola
./swap
Podemos combinar el parámetro -type con -name para encontrar los ficheros ocultos:
[BASH]# find . -type f -name .*
./.bash_profile
./.bash_logout
./.bashrc
./.cshrc
./.tcshrc
./.lesshst
Lo cual nos sirve igual para directorios ocultos:
[BASH]# find . -type d -name .*
.
./.ssh
./.cpan
./.spamassassin
./.subversion
./.gnupg
./.lftp
Origen: linuxparatodos






