Skip to content
Myr

Move command execution section

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Peter · committed by David Peter · parent 5423c45 · Browse files · 1 file+33 added−33 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+33 added−33 removed

  • other:+33 added−33 removed

1 file+33 added−33 removed

modified:README.md+33 added-33 removed
135 unmodified lines
136137To really search *all* files and directories, simply combine the hidden and ignore features to show138everything (`-HI`).139140### Excluding specific files or directories141142Sometimes we want to ignore search results from a specific subdirectory. For example, we might143want to search all hidden files and directories (`-H`) but exclude all matches from `.git`144directories. We can use the `-E` (or `--exclude`) option for this. It takes an arbitrary glob145pattern as an argument:146``` bash147> fd -H -E .git …148```149150We can also use this to skip mounted directories:151``` bash152> fd -E /mnt/external-drive …153```154155.. or to skip certain file types:156``` bash157> fd -E '*.bak' …158```159160To make exclude-patterns like these permanent, you can create a `.fdignore` file. They work like161`.gitignore` files, but are specific to `fd`. For example:162``` bash163> cat ~/.fdignore164/mnt/external-drive165*.bak166```167Note: `fd` also supports `.ignore` files that are used by other programs such as `rg` or `ag`.168169If you want `fd` to ignore these patterns globally, you can put them in `fd`'s global ignore file.170This is usually located in `~/.config/fd/ignore` in macOS or Linux, and `%APPDATA%\fd\ignore` in171Windows.172140### Command execution141142Instead of just showing the search results, you often want to *do something* with them. `fd`143provides two ways to execute external commands for each of your search results:
56 unmodified lines
200201For `-x`/`--exec`, you can control the number of parallel jobs by using the `-j`/`--threads` option.202Use `--threads=1` for serial execution.203204### Excluding specific files or directories205206Sometimes we want to ignore search results from a specific subdirectory. For example, we might207want to search all hidden files and directories (`-H`) but exclude all matches from `.git`208directories. We can use the `-E` (or `--exclude`) option for this. It takes an arbitrary glob209pattern as an argument:210``` bash211> fd -H -E .git …212```213214We can also use this to skip mounted directories:215``` bash216> fd -E /mnt/external-drive …217```218219.. or to skip certain file types:220``` bash221> fd -E '*.bak' …222```223224To make exclude-patterns like these permanent, you can create a `.fdignore` file. They work like225`.gitignore` files, but are specific to `fd`. For example:226``` bash227> cat ~/.fdignore228/mnt/external-drive229*.bak230```231Note: `fd` also supports `.ignore` files that are used by other programs such as `rg` or `ag`.232233If you want `fd` to ignore these patterns globally, you can put them in `fd`'s global ignore file.234This is usually located in `~/.config/fd/ignore` in macOS or Linux, and `%APPDATA%\fd\ignore` in235Windows.236237### Deleting files238239You can use `fd` to remove all files and directories that are matched by your search pattern.240If you only want to remove files, you can use the `--exec-batch`/`-X` option to call `rm`. For
397 unmodified lines