Skip to content
Myr

README.md

This file

Path

README.md

293 lines · 10.5 KiB · Markdown

Last changed by

README and man page updates.sharkdpbefore adoption7b8d932

History of this file

Take it

Re-write in rustsharkdpbefore adoption12bfee0

line 1why, one step back
1# fd

README updatessharkdpbefore adoption92e2fd3

line 2why, one step back
2[![Build Status](https://travis-ci.org/sharkdp/fd.svg?branch=master)](https://travis-ci.org/sharkdp/fd)

Add badgessharkdpbefore adoption8073635

line 3why, one step back
3[![Build status](https://ci.appveyor.com/api/projects/status/21c4p5fwggc5gy3j?svg=true)](https://ci.appveyor.com/project/sharkdp/fd)

Add crates.io badgeDavid Peterbefore adoptiond8c588d

line 4why, one step back
4[![Version info](https://img.shields.io/crates/v/fd-find.svg)](https://crates.io/crates/fd-find)

FeaturesDavid Peterbefore adoption490c1ef

line 5why, one step back
5

Update READMEsharkdpbefore adoption7f49489

lines 6–7why, one step back
6*fd* is a simple, fast and user-friendly alternative to
7[*find*](https://www.gnu.org/software/findutils/).

README updatessharkdpbefore adoption92e2fd3

line 8why, one step back
8

Update READMEsharkdpbefore adoption7f49489

lines 9–10why, one step back
9While it does not seek to mirror all of *find*'s powerful functionality, it provides sensible
10(opinionated) defaults for [80%](https://en.wikipedia.org/wiki/Pareto_principle) of the use cases.

Update README.mdDavid Peterbefore adoption8e41713

line 11why, one step back
11

README updatessharkdpbefore adoption92e2fd3

lines 12–13why, one step back
12## Features
13* Convenient syntax: `fd PATTERN` instead of `find -iname '*PATTERN*'`.

Update benchmark resultsDavid Peterbefore adoptiond67b1bb

line 14why, one step back
14* Colorized terminal output (similar to *ls*).

Link to benchmark sectionDavid Peterbefore adoption0cd9d8c

line 15why, one step back
15* It's *fast* (see [benchmarks](#benchmark) below).

Update README.mdDavid Peterbefore adoption8e41713

lines 16–18why, one step back
16* Smart case: the search is case-insensitive by default. It switches to
17 case-sensitive if the pattern contains an uppercase18 character[\*](http://vimdoc.sourceforge.net/htmldoc/options.html#'smartcase').

Update README.mdDavid Peterbefore adoption7b1a457

lines 19–22why, one step back
19* Ignores hidden directories and files, by default.
20* Ignores patterns from your `.gitignore`, by default.21* Regular expressions.22* Unicode-awareness.

Update READMEsharkdpbefore adoption7f49489

lines 23–24why, one step back
23* The command name is *50%* shorter[\*](https://github.com/ggreer/the_silver_searcher) than
24 `find` :-).

Merge pull request #116 from mmstick/execDavid Peterbefore adoptione0eab07

line 25why, one step back
25* Parallel command execution with a syntax similar to GNU Parallel.

Build instructionsDavid Peterbefore adoption8acb30b

line 26why, one step back
26

Update README.mdDavid Peterbefore adoption6a705b5

line 27why, one step back
27## Demo

Update README.mdDavid Peterbefore adoptionb97038f

line 28why, one step back
28

Update demo videoDavid Peterbefore adoption3afd216

line 29why, one step back
29![Demo](http://i.imgur.com/kTMFSVU.gif)

ExamplesDavid Peterbefore adoptiondddd47e

line 30why, one step back
30

Added benchmark resultsDavid Peterbefore adoption7b00772

line 31why, one step back
31## Benchmark

Update benchmark resultsDavid Peterbefore adoptiond67b1bb

lines 32–37why, one step back
32Let's search my home folder for files that end in `[0-9].jpg`. It contains ~150.000
33subdirectories and about a million files. For averaging and statistical analysis, I'm using34[bench](https://github.com/Gabriel439/bench). All benchmarks are performed for a "warm35cache". Results for a cold cache are similar.3637Let's start with `find`:

Update benchmark results, see #31sharkdpbefore adoptionc74c2ca

line 38why, one step back
38```

Update benchmark resultsDavid Peterbefore adoptiond67b1bb

lines 39–41why, one step back
39find ~ -iregex '.*[0-9]\.jpg$'
4041time 6.265 s (6.127 s .. NaN s)

Update benchmark results, see #31sharkdpbefore adoptionc74c2ca

line 42why, one step back
42 1.000 R² (1.000 R² .. 1.000 R²)

Update benchmark resultsDavid Peterbefore adoptiond67b1bb

lines 43–45why, one step back
43mean 6.162 s (6.140 s .. 6.181 s)
44std dev 31.73 ms (0.0 s .. 33.48 ms)45```

Added benchmark resultsDavid Peterbefore adoption7b00772

line 46why, one step back
46

Update benchmark resultsDavid Peterbefore adoptiond67b1bb

lines 47–51why, one step back
47`find` is much faster if it does not need to perform a regular-expression search:
48```49find ~ -iname '*[0-9].jpg'5051time 2.866 s (2.754 s .. 2.964 s)

Update benchmark results, see #31sharkdpbefore adoptionc74c2ca

line 52why, one step back
52 1.000 R² (0.999 R² .. 1.000 R²)

Update benchmark resultsDavid Peterbefore adoptiond67b1bb

lines 53–54why, one step back
53mean 2.860 s (2.834 s .. 2.875 s)
54std dev 23.11 ms (0.0 s .. 25.09 ms)

Added benchmark resultsDavid Peterbefore adoption7b00772

line 55why, one step back
55```

Update benchmark results, see #31sharkdpbefore adoptionc74c2ca

line 56why, one step back
56

Update benchmark resultsDavid Peterbefore adoptiond67b1bb

lines 57–61why, one step back
57Now let's try the same for `fd`. Note that `fd` *always* performs a regular expression
58search. The options `--hidden` and `--no-ignore` are needed for a fair comparison,59otherwise `fd` does not have to traverse hidden folders and ignored paths (see below):60```61fd --hidden --no-ignore '.*[0-9]\.jpg$' ~

Added benchmark resultsDavid Peterbefore adoption7b00772

line 62why, one step back
62

Update benchmark resultsDavid Peterbefore adoptiond67b1bb

lines 63–88why, one step back
63time 892.6 ms (839.0 ms .. 915.4 ms)
64 0.999 R² (0.997 R² .. 1.000 R²)65mean 871.2 ms (857.9 ms .. 881.3 ms)66std dev 15.50 ms (0.0 s .. 17.49 ms)67```68For this particular example, `fd` is approximately seven times faster than `find -iregex`69and about three times faster than `find -iname`. By the way, both tools found the exact70same 14030 files :smile:.7172Finally, let's run `fd` without `--hidden` and `--no-ignore` (this can lead to different73search results, of course):74```75fd '[0-9]\.jpg$' ~7677time 159.5 ms (155.8 ms .. 165.3 ms)78 0.999 R² (0.996 R² .. 1.000 R²)79mean 158.7 ms (156.5 ms .. 161.6 ms)80std dev 3.263 ms (2.401 ms .. 4.298 ms)81```8283**Note**: This is *one particular* benchmark on *one particular* machine. While I have84performed quite a lot of different tests (and found consistent results), things might85be different for you! I encourage everyone to try it out on their own.8687Concerning *fd*'s speed, the main credit goes to the `regex` and `ignore` crates that are also used88in [ripgrep](https://github.com/BurntSushi/ripgrep) (check it out!).

Link to benchmark sectionDavid Peterbefore adoption0cd9d8c

lines 89–98why, one step back
89
90## Colorized output91`fd` can colorize files by extension, just like `ls`. In order for this to work, the environment92variable [`LS_COLORS`](https://linux.die.net/man/5/dir_colors) has to be set. Typically, the value93of this variable is set by the `dircolors` command which provides a convenient configuration format94to define colors for different file formats.95On most distributions, `LS_COLORS` should be set already. If you are looking for alternative, more96complete (and more colorful) variants, see97[here](https://github.com/seebi/dircolors-solarized) or98[here](https://github.com/trapd00r/LS_COLORS).

Merge pull request #116 from mmstick/execDavid Peterbefore adoptione0eab07

line 99why, one step back
99

Updates for the parallel command execution partsharkdpbefore adoption7ecb623

lines 100–103why, one step back
100## Parallel command execution
101If the `-x`/`--exec` option is specified alongside a command template, a job pool will be created102for executing commands in parallel for each discovered path as the input. The syntax for generating103commands is similar to that of GNU Parallel:

Merge pull request #116 from mmstick/execDavid Peterbefore adoptione0eab07

line 104why, one step back
104

Updates for the parallel command execution partsharkdpbefore adoption7ecb623

lines 105–110why, one step back
105- `{}`: A placeholder token that will be replaced with the path of the search result
106 (`documents/images/party.jpg`).107- `{.}`: Like `{}`, but without the file extension (`documents/images/party`).108- `{/}`: A placeholder that will be replaced by the basename of the search result (`party.jpg`).109- `{//}`: Uses the parent of the discovered path (`documents/images`).110- `{/.}`: Uses the basename, with the extension removed (`party`).

Merge pull request #116 from mmstick/execDavid Peterbefore adoptione0eab07

line 111why, one step back
111

Updates for the parallel command execution partsharkdpbefore adoption7ecb623

lines 112–113why, one step back
112``` bash
113# Convert all jpg files to png files

Fix --exec examples in READMEsharkdpbefore adoption19afb15

line 114why, one step back
114fd -e jpg -x 'convert {} {.}.png'

Merge pull request #116 from mmstick/execDavid Peterbefore adoptione0eab07

line 115why, one step back
115

Updates for the parallel command execution partsharkdpbefore adoption7ecb623

lines 116–117why, one step back
116# Unpack all zip files (if no placeholder is given, the path is appended):
117fd -e zip -x unzip

Merge pull request #116 from mmstick/execDavid Peterbefore adoptione0eab07

line 118why, one step back
118

Updates for the parallel command execution partsharkdpbefore adoption7ecb623

line 119why, one step back
119# Convert all flac files into opus files:

Fix --exec examples in READMEsharkdpbefore adoption19afb15

line 120why, one step back
120fd -e flac -x 'ffmpeg -i {} -c:a libopus {.}.opus'

Merge pull request #116 from mmstick/execDavid Peterbefore adoptione0eab07

line 121why, one step back
121```

Add note about regex and ignore cratesDavid Peterbefore adoptionb347160

line 122why, one step back
122

Update install instructionsDavid Peterbefore adoptiona4e48cf

line 123why, one step back
123## Install

Add new cargo install instructionssharkdpbefore adoptionf1f537b

line 124why, one step back
124With Rust's package manager [cargo](https://github.com/rust-lang/cargo), you can install *fd* via:

Update install instructionsDavid Peterbefore adoptiona4e48cf

line 125why, one step back
125```

Add new cargo install instructionssharkdpbefore adoptionf1f537b

line 126why, one step back
126cargo install fd-find

Update install instructionsDavid Peterbefore adoptiona4e48cf

line 127why, one step back
127```

README and man page updates.sharkdpbefore adoption7b8d932

line 128why, one step back
128Note that rust version *1.19.0* or later is required.

Update install instructionsDavid Peterbefore adoptiona4e48cf

line 129why, one step back
129The release page of this repository also includes precompiled binaries for Linux.

Update install instructionsDavid Peterbefore adoptioneb72875

line 130why, one step back
130

Add link to Homebrew formulaDavid Peterbefore adoption6c69b98

line 131why, one step back
131On **macOS**, you can use [Homebrew](http://braumeister.org/formula/fd):

Update install instructionsDavid Peterbefore adoptioneb72875

lines 132–134why, one step back
132```
133brew install fd134```

Added benchmark resultsDavid Peterbefore adoption7b00772

line 135why, one step back
135

README: Arch Linux has package fd-rs in official reposBen Morganbefore adoption200dfaa

line 136why, one step back
136On **Arch Linux**, you can install the package from the official repos:

Merge pull request #51 from wezm/patch-1David Peterbefore adoptionfb5ba2c

line 137why, one step back
137```

README: Arch Linux has package fd-rs in official reposBen Morganbefore adoption200dfaa

line 138why, one step back
138pacman -S fd-rs

Merge pull request #51 from wezm/patch-1David Peterbefore adoptionfb5ba2c

lines 139–140why, one step back
139```
140

Added another way of installationMattbefore adoption08aa06a

lines 141–145why, one step back
141On **NixOS**, or any Linux distro you can use [Nix](https://nixos.org/nix/):
142```143nix-env -i fd144```145

Update README.mdOli Lalondebefore adoption68a85c7

line 146why, one step back
146On **Windows**, you can download the pre-built binaries from the [Release page](https://github.com/sharkdp/fd/releases).

Add Windows install instructionsDavid Peterbefore adoption43b124c

line 147why, one step back
147

Update install instructionsDavid Peterbefore adoptiona4e48cf

line 148why, one step back
148## Development

Build instructionsDavid Peterbefore adoption8acb30b

line 149why, one step back
149```bash

Update development instructionssharkdpbefore adoption4884c23

lines 150–155why, one step back
150git clone https://github.com/sharkdp/fd
151152# Build153cd fd154cargo build155

Update development instructionsDavid Peterbefore adoptionb98e4c9

line 156why, one step back
156# Run unit tests and integration tests

Update development instructionssharkdpbefore adoption4884c23

lines 157–160why, one step back
157cargo test
158159# Install160cargo install

Build instructionsDavid Peterbefore adoption8acb30b

line 161why, one step back
161```

Add command-line optionssharkdpbefore adoptiona234984

lines 162–170why, one step back
162
163## Command-line options164```165USAGE:166 fd [FLAGS/OPTIONS] [<pattern>] [<path>]167168FLAGS:169 -H, --hidden Search hidden files and directories170 -I, --no-ignore Do not respect .(git)ignore files

Update USAGE.David Peterbefore adoption083b1cf

line 171why, one step back
171 -s, --case-sensitive Case-sensitive search (default: smart case)

Updates and preparations for v5.0sharkdpbefore adoptione9cf8af

line 172why, one step back
172 -i, --ignore-case Case-insensitive search (default: smart case)

Add command-line optionssharkdpbefore adoptiona234984

line 173why, one step back
173 -a, --absolute-path Show absolute instead of relative paths

Update USAGE.David Peterbefore adoption083b1cf

lines 174–176why, one step back
174 -L, --follow Follow symbolic links
175 -p, --full-path Search full path (default: file-/dirname only)176 -0, --print0 Separate results by the null character

Add command-line optionssharkdpbefore adoptiona234984

lines 177–180why, one step back
177 -h, --help Prints help information
178 -V, --version Prints version information179180OPTIONS:

README and man page updates.sharkdpbefore adoption7b8d932

lines 181–188why, one step back
181 -d, --max-depth <depth> Set maximum search depth (default: none)
182 -t, --type <filetype> Filter by type: f(ile), d(irectory), (sym)l(ink)183 -e, --extension <ext> Filter by file extension184 -x, --exec <cmd> Execute the given command for each search result185 -E, --exclude <pattern>... Exclude entries that match the given glob pattern.186 -c, --color <when> When to use colors: never, *auto*, always187 -j, --threads <num> Set number of threads to use for searching &188 executing

Add command-line optionssharkdpbefore adoptiona234984

lines 189–193why, one step back
189
190ARGS:191 <pattern> the search pattern, a regular expression (optional)192 <path> the root directory for the filesystem search (optional)193```

Add examples to README (#68)Rickybefore adoption3b55edf

line 194why, one step back
194

First update for tutorialsharkdpbefore adoption080e8a9

line 195why, one step back
195## Tutorial

Add examples to README (#68)Rickybefore adoption3b55edf

line 196why, one step back
196

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 197–199why, one step back
197First, to get an overview of all available command line options, you can either run
198`fd -h` for a concise help message (see above) or `fd --help` for a more detailed199version.

Add examples to README (#68)Rickybefore adoption3b55edf

line 200why, one step back
200

Updates for the tutorialsharkdpbefore adoption5863a5e

line 201why, one step back
201### Simple search

Add examples to README (#68)Rickybefore adoption3b55edf

line 202why, one step back
202

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 203–208why, one step back
203*fd* is designed to find entries in your filesystem. The most basic search you can perform is to
204run *fd* with a single argument: the search pattern. For example, assume that you want to find an205old script of yours (the name included `netflix`):206``` bash207> fd netfl208Software/python/imdb-ratings/netflix-details.py

Updated tutorial with real-world examplessharkdpbefore adoptiond32fe02

line 209why, one step back
209```

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 210–211why, one step back
210If called with just a single argument like this, *fd* searches the current directory recursively
211for any entries that *contain* the pattern `netfl`.

Updated tutorial with real-world examplessharkdpbefore adoptiond32fe02

line 212why, one step back
212

Updates for the tutorialsharkdpbefore adoption5863a5e

line 213why, one step back
213### Regular expression search

Updated tutorial with real-world examplessharkdpbefore adoptiond32fe02

line 214why, one step back
214

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 215–221why, one step back
215The search pattern is treated as a regular expression. Here, we search for entries that start
216with `x` and end with `rc`:217``` bash218> cd /etc219> fd '^x.*rc$'220X11/xinit/xinitrc221X11/xinit/xserverrc

Add examples to README (#68)Rickybefore adoption3b55edf

lines 222–223why, one step back
222```
223

Updates for the tutorialsharkdpbefore adoption5863a5e

line 224why, one step back
224### Specifying the root directory

Add examples to README (#68)Rickybefore adoption3b55edf

line 225why, one step back
225

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 226–231why, one step back
226If we want so search a specific directory, it can be given as a second argument to *fd*:
227``` bash228> fd passwd /etc229/etc/default/passwd230/etc/pam.d/passwd231/etc/passwd

Add examples to README (#68)Rickybefore adoption3b55edf

lines 232–233why, one step back
232```
233

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 234–243why, one step back
234### Running *fd* without any arguments
235236*fd* can be called with no arguments. This is very useful to get a quick overview of all entries237in the current directory, recursively (similar to `ls -R`):238``` bash239> cd fd/tests240> fd241testenv242testenv/mod.rs243tests.rs

Add examples to README (#68)Rickybefore adoption3b55edf

lines 244–245why, one step back
244```
245

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 246–254why, one step back
246### Searching for a particular file extension
247248Often, we are interested in all files of a particular type. This can be done with the `-e` (or249`--extension`) option. Here, we search for all Markdown files in the fd repository:250``` bash251> cd fd252> fd -e md253CONTRIBUTING.md254README.md

Add examples to README (#68)Rickybefore adoption3b55edf

lines 255–256why, one step back
255```
256

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 257–262why, one step back
257The `-e` option can be used in combination with a search pattern:
258``` bash259> fd -e rs mod260src/fshelper/mod.rs261src/lscolors/mod.rs262tests/testenv/mod.rs

Add examples to README (#68)Rickybefore adoption3b55edf

lines 263–264why, one step back
263```
264

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 265–271why, one step back
265### Hidden and ignored files
266By default, *fd* does not search hidden directories and does not show hidden files in the267search results. To disable this behavior, we can use the `-H` (or `--hidden`) option:268``` bash269> fd pre-commit270> fd -H pre-commit271.git/hooks/pre-commit.sample

Add examples to README (#68)Rickybefore adoption3b55edf

lines 272–273why, one step back
272```
273

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 274–280why, one step back
274If we work in a directory that is a Git repository (or includes Git repositories), *fd* does not
275search folders (and does not show files) that match one of the `.gitignore` patterns. To disable276this behavior, we can use the `-I` (or `--ignore`) option:277``` bash278> fd num_cpu279> fd -I num_cpu280target/debug/deps/libnum_cpus-f5ce7ef99006aa05.rlib

Add examples to README (#68)Rickybefore adoption3b55edf

lines 281–282why, one step back
281```
282

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 283–284why, one step back
283To really search *all* files and directories, simply combine the hidden and ignore features to show
284everything (`-HI`).

Updated tutorial with real-world examplessharkdpbefore adoptiond32fe02

line 285why, one step back
285

Updates for the tutorialsharkdpbefore adoption5863a5e

line 286why, one step back
286### Using fd with `xargs` or `parallel`

Updated tutorial with real-world examplessharkdpbefore adoptiond32fe02

line 287why, one step back
287

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 288–290why, one step back
288If we want to run a command on all search results, we can pipe the output to `xargs`:
289``` bash290> fd -0 -e rs | xargs -0 wc -l

Add examples to README (#68)Rickybefore adoption3b55edf

line 291why, one step back
291```

Updates for the tutorialsharkdpbefore adoption5863a5e

lines 292–293why, one step back
292Here, the `-0` option tells *fd* to separate search results by the NULL character (instead of .
293newlines) In the same way, the `-0` option of `xargs` tells it to read the input in this way .