188 lines
5.9 KiB
Markdown
188 lines
5.9 KiB
Markdown
# fd
|
||
|
||
(alternative à [find](find.md)) (macOS / Linux / Windows)
|
||
|
||
https://github.com/sharkdp/fd
|
||
|
||
|
||
|
||
```bash
|
||
$ brew install fd
|
||
```
|
||
|
||
```
|
||
choco install fd
|
||
```
|
||
|
||
|
||
|
||
##### Recherche un fichier dans le répertoire courant (et sous-dossiers):
|
||
|
||
```bash
|
||
~ master* ⇡
|
||
❯ fd -H .zshrc
|
||
.zshrc
|
||
|
||
~/.config master* ⇡
|
||
❯ fd -HI pip.conf
|
||
pip/pip.conf
|
||
|
||
```
|
||
|
||
##### Recherche dans un répertoire particulier:
|
||
|
||
```bash
|
||
$ fd -HI 'id_*' .ssh
|
||
.ssh/id_ed25519
|
||
.ssh/id_ed25519.pub
|
||
.ssh/id_rsa
|
||
.ssh/id_rsa.pub
|
||
.ssh/id_rsa.zip
|
||
|
||
❯ fd -HI 'id_*' $HOME/.ssh
|
||
/Users/bruno/.ssh/id_ed25519
|
||
/Users/bruno/.ssh/id_ed25519.pub
|
||
/Users/bruno/.ssh/id_rsa
|
||
/Users/bruno/.ssh/id_rsa.pub
|
||
```
|
||
|
||
##### Recherche par regex:
|
||
|
||
```bash
|
||
$ fd -I '^.*.conf$' /opt
|
||
/opt/homebrew/share/autoconf
|
||
/opt/homebrew/share/user_map.conf
|
||
/opt/homebrew/Cellar/mariadb/10.6.4/share/user_map.conf
|
||
/opt/homebrew/Cellar/groonga/11.0.5/etc/groonga/groonga.conf
|
||
/opt/homebrew/Cellar/groonga/11.0.5/etc/groonga/httpd/fastcgi.conf
|
||
...
|
||
|
||
$ fd -H '^.*.conf$' /opt
|
||
|
||
$
|
||
```
|
||
|
||
https://docs.rs/regex/1.0.0/regex/#syntax
|
||
|
||
##### Fichiers se terminant par *'[0-9].jpg'*:
|
||
|
||
```bash
|
||
$ fd -HI '.*[0-9]\.jpg$' ~
|
||
|
||
$ find ~ -iname '*[0-9].jpg'
|
||
```
|
||
|
||
##### Sans arguments:
|
||
|
||
```bash
|
||
# afficher tous les entrées du répertoire courant
|
||
$ fd
|
||
|
||
# afficher tous les entrées d'un répertoire
|
||
$ fd . $HOME/.ssh
|
||
/Users/bruno/.ssh/config
|
||
/Users/bruno/.ssh/id_ed25519
|
||
/Users/bruno/.ssh/id_ed25519.pub
|
||
/Users/bruno/.ssh/id_rsa
|
||
/Users/bruno/.ssh/id_rsa.pub
|
||
/Users/bruno/.ssh/known_hosts
|
||
```
|
||
|
||
##### Chercher un fichier précis:
|
||
|
||
```bash
|
||
$ fd -I -g php.ini /opt
|
||
/opt/homebrew/etc/php/7.4/php.ini
|
||
/opt/homebrew/etc/php/8.0/php.ini
|
||
```
|
||
|
||
|
||
|
||
#### Option:
|
||
|
||
- **-H, --hidden**: cherche dans les fichiers et dossiers cachés
|
||
- **-I, --no-ignore**: cherche dans les fichiers et dossiers ignorés par '.gitignore', '.ignore', '.fdignore'
|
||
- **-x, --exec <cmd>**: exécute une commande pour chaque résultat
|
||
- **-X, --exec-batch <cmd>**: exécute une commande pour tous les résultats en même temps
|
||
- **-s, --case-sensitive**:
|
||
- **-i, --ignore-case**: (défaut)
|
||
- **-l, --list-details**
|
||
- **-L, --follow**: suit les liens symboliques (pas par défaut)
|
||
- **-d, --max-depth <depth>**: limite le nombre de répertoires traversés (pas de limite par défaut)
|
||
- **-t, --type <filetype>...**: filtre par type de fichiers
|
||
- 'f' or 'file': fichiers réguliers
|
||
- 'd' or 'directory': répertoires
|
||
- 'l' or 'symlink': liens symboliques
|
||
- 'x' or 'executable': executables
|
||
- 'e' or 'empty': fichiers vides ou répertoires
|
||
- 's' or 'socket': socket
|
||
- 'p' or 'pipe': named pipe (FIFO)
|
||
- **-e, --extension <ext>...**: filtre par extension (plusieurs autorisées)
|
||
- **-E, --exclude <pattern>...**: exclure des fichiers/répertoires des résultats (--exclude '*.pyc', --exclude node_modules)
|
||
- **-c, --color <when>**: colorie chaque chaine trouvée ('auto', 'never', 'always')
|
||
- **-S, --size <size>...**: filtre par la taille des fichiers (+3k, -500, +1g, 300)
|
||
- **--changed-within <date|dur>**: filtre par la date de modification
|
||
- --changed-within 2 weeks (10h, 1d, 35min)
|
||
- --change-newer-than '2018-10-27 10:00:00'
|
||
- **--changed-before <date|dur>**: filtre par la date de modification
|
||
- --changed-before '2018-10-27 10:00:00'
|
||
- --change-older-than 2weeks (10h, 1d, 35min)
|
||
- **-o, --owner <user:group>**: filtre par utilisateur/groupe (--owner bruno, --owner :staff, --owner '!john:students')
|
||
- **--max-results <count>**: limite le nombre de résultats à 'count' et quitte
|
||
|
||
|
||
|
||
```bash
|
||
# -l, --list-details
|
||
|
||
$ fd -Il '^.*.conf$' /opt/homebrew/etc
|
||
-rw-r--r-- 1 bruno admin 696 jul 24 07:46 /opt/homebrew/etc/fonts/conf.d/10-hinting-slight.conf
|
||
-rw-r--r-- 1 bruno admin 2,2K jul 24 07:46 /opt/homebrew/etc/fonts/conf.d/10-scale-bitmap-fonts.conf
|
||
-rw-r--r-- 1 bruno admin 1,6K jul 24 07:46 /opt/homebrew/etc/fonts/conf.d/20-unhint-small-vera.conf
|
||
```
|
||
|
||
|
||
|
||
```bash
|
||
$ 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.
|
||
```
|
||
|