linux:utils:find-fd

find - fd

sudo apt install fd-find
sudo ln -s /usr/lib/cargo/bin/fd /usr/local/bin/fd

https://docs.rs/regex/latest/regex/#syntax

  • por defecto
  • ^: empieza
  • $: acaba
  • buscar -:
    fd -- '-pattern'
    fd '[-]pattern'
  • --ignore-case
    • por defecto: todo minúsculas, no distingue. Si alguna mayúscula, distingue.
  • -e: extensión
    • ^c.*png$
    • .*.pdf
  • --type | -t: tipo
    • f: fichero
    • d: directorio
    • l: enlace simbólico
    • x: ejecutable
    • e: 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 de fd . -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)

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
  • ~/.config/fd/ignore: global
  • variable LS_COLORS
  • varibale NO_COLORº
  • 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
  • linux/utils/find-fd.txt
  • Darrera modificació: 19/11/2025 00:02
  • per mate