Files
mkdocs/docs/Linux/fd.md
2021-02-04 09:55:26 +01:00

3.3 KiB
Raw Blame History

fd

(alternative à find) (macOS / Linux / Windows)

$ brew install fd
choco install fd

Recherche un fichier dans le répertoire courant (et sous-dossiers):

~ master* ⇡
 fd -H .zshrc
.zshrc

~/.config master* ⇡
 fd -HI pip.conf
pip/pip.conf

Recherche dans un répertoire particulier:

~ master* ⇡
 fd -HI 'id_*' .ssh
.ssh/id_ed25519
.ssh/id_ed25519.pub
.ssh/id_rsa
.ssh/id_rsa.pub
.ssh/id_rsa.zip

Recherche par regex:

~ master* ⇡ 4m 27s
 fd -HI '^h.*.conf$' /etc
/etc/apache2/extra/httpd-autoindex.conf
/etc/apache2/extra/httpd-dav.conf
/etc/apache2/extra/httpd-default.conf
/etc/apache2/extra/httpd-info.conf
/etc/apache2/extra/httpd-languages.conf
/etc/apache2/extra/httpd-manual.conf
/etc/apache2/extra/httpd-mpm.conf
/etc/apache2/extra/httpd-multilang-errordoc.conf
/etc/apache2/extra/httpd-ssl.conf
/etc/apache2/extra/httpd-userdir.conf
/etc/apache2/extra/httpd-vhosts.conf
/etc/apache2/httpd.conf
...

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

Fichiers se terminant par '[0-9].jpg':

$ fd -HI '.*[0-9]\.jpg$' ~

$ find ~ -iname '*[0-9].jpg'

Sans arguments:

Option:

  • --hidden: cherche dans les dossiers cachés
  • --no-ignore:
  • -x / --exec:
$ fd -h
fd 8.1.1 

USAGE:
    fd [FLAGS/OPTIONS] [<pattern>] [<path>...]

FLAGS:
    -H, --hidden            Search hidden files and directories
    -I, --no-ignore         Do not respect .(git|fd)ignore files
    -s, --case-sensitive    Case-sensitive search (default: smart case)
    -i, --ignore-case       Case-insensitive search (default: smart case)
    -g, --glob              Glob-based search (default: regular expression)
    -a, --absolute-path     Show absolute instead of relative paths
    -l, --list-details      Use a long listing format with file metadata
    -L, --follow            Follow symbolic links
    -p, --full-path         Search full path (default: file-/dirname only)
    -0, --print0            Separate results by the null character
    -h, --help              Prints help information
    -V, --version           Prints version information

OPTIONS:
    -d, --max-depth <depth>            Set maximum search depth (default: none)
    -t, --type <filetype>...           Filter by type: file (f), directory (d), symlink (l),
                                       executable (x), empty (e), socket (s), pipe (p)
    -e, --extension <ext>...           Filter by file extension
    -x, --exec <cmd>                   Execute a command for each search result
    -X, --exec-batch <cmd>             Execute a command with all search results at once
    -E, --exclude <pattern>...         Exclude entries that match the given glob pattern
    -c, --color <when>                 When to use colors: never, *auto*, always
    -S, --size <size>...               Limit results based on the size of files.
        --changed-within <date|dur>    Filter by file modification time (newer than)
        --changed-before <date|dur>    Filter by file modification time (older than)
    -o, --owner <user:group>           Filter by owning user and/or group

ARGS:
    <pattern>    the search pattern - a regular expression unless '--glob' is used (optional)
    <path>...    the root directory for the filesystem search (optional)

Note: `fd -h` prints a short and concise overview while `fd --help` gives all details.