find - fd
install
sudo apt install fd-find sudo ln -s /usr/lib/cargo/bin/fd /usr/local/bin/fd
regexp
https://docs.rs/regex/latest/regex/#syntax
- por defecto
^: empieza$: acaba- buscar
-:fd -- '-pattern' fd '[-]pattern'
parámetros
--ignore-case- por defecto: todo minúsculas, no distingue. Si alguna mayúscula, distingue.
-e: extensión^c.*png$.*.pdf
--type|-t: tipof: ficherod: directoriol: enlace simbólicox: ejecutablee: fichero vacío
--changed-whithin Nd: busca ficheros cambiados en los N días--exclude-dir '<PATRON>'|-E: excluye de la búsqueda el patrón--size '<SIZE>'-x <comando>: buscar y ejecutar comando para cada fichero-X <comando>: buscar y ejectuar comando una vez con todos los resultados--regexp <regexp>--perm <PERM 777>--hidden|-H: buscar en directorios o ficheros ocultos (dot)--no-ignore|-I: no ignorar ficheros contenidos en .gitignore--full-path|-p: busca por full path y no solo por nombre (de fichero o directorio)--list-details|-l: alias defd . -X ls -lhd –color=always, mostrando detalles del fichero (owner, perms, …)--threads|-j: número de ejecuciones paralelas =1 es en serie (modo por defecto)The terminal output of commands run from parallel threads using -x will not be interlaced or garbled, so fd -x can be used to rudimentarily parallelize a task run over many files. An example of this is calculating the checksum of each individual file within a directory.
--unrestricted|-u: busca en ficheros ocultos e ignorados (parámetros HI)
placeholder
Sustituciones usadas en búsquedas y ejecuciones sobre el nombre de los archivos
{}: A placeholder token that will be replaced with the path of the search result (documents/images/party.jpg).{.}: Like {}, but without the file extension (documents/images/party).{/}: A placeholder that will be replaced by the basename of the search result (party.jpg).{//}: The parent of the discovered path (documents/images).{/.}: The basename, with the extension removed (party).
ignore
.ignore~/.config/fd/ignore: global
colors
- variable
LS_COLORS - varibale
NO_COLORº
ejemplos
- Recursively find all zip archives and unpack them:
fd -e zip -x unzip
- Find all test_*.py files and open them in your favorite editor. Note that we use capital -X here to open a single vim instance. If there are two such files, test_basic.py and lib/test_advanced.py, this will run vim test_basic.py lib/test_advanced.py.:
fd -g 'test_*.py' -X vim
- To see details like file permissions, owners, file sizes etc., you can tell fd to show them by running ls for each result:
fd … -X ls -lhd --color=always fd … -l
- Convert all *.jpg files to *.png files:
fd -e jpg -x convert {} {.}.png
- mirar placeholders
- To format the output of fd as a file-tree you can use the tree command with –fromfile:
fd | tree --fromfile