diff --git a/README.md b/README.md index 37a7c46..57a6e18 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1253 TILs and counting..._ +_1254 TILs and counting..._ --- @@ -1200,6 +1200,7 @@ _1253 TILs and counting..._ - [Exclude Certain Files From An rsync Run](unix/exclude-certain-files-from-an-rsync-run.md) - [Figure Out The Week Of The Year From The Terminal](unix/figure-out-the-week-of-the-year-from-the-terminal.md) - [File Type Info With File](unix/file-type-info-with-file.md) +- [Find All Files Matching A Name With fd](unix/find-all-files-matching-a-name-with-fd.md) - [Find A File Installed By Brew](unix/find-a-file-installed-by-brew.md) - [Find Files With fd](unix/find-files-with-fd.md) - [Find Newer Files](unix/find-newer-files.md) diff --git a/unix/find-all-files-matching-a-name-with-fd.md b/unix/find-all-files-matching-a-name-with-fd.md new file mode 100644 index 0000000..ec7e12c --- /dev/null +++ b/unix/find-all-files-matching-a-name-with-fd.md @@ -0,0 +1,34 @@ +# Find All Files Matching A Name With fd + +The [`fd` command](https://github.com/sharkdp/fd) can be used to find files in +your file system by name. Though it has some nice defaults—it excludes hidden +directories and respects your `.gitignore` file—you may need to configure +those. + +For instance, I want to find ALL _sitemap_ files in a monorepo. + +```bash +$ fd -I -H sitemap.xml +``` + +The `-I` flag tells `fd` to not respect the `.gitignore` file. The `-H` flag +says to include hidden directories in the recursive search. + +This included a bit too much noise from the `node_modules` directory, so I want +to exclude that. + +```bash +$ fd -I -H -E node_modules sitemap.xml +``` + +The `-E` flag can specify one-off directories to exclude from the search. + +I can even specify a regex to make sure I capture files that look like +`sitemap-01.xml`, not just `sitemap.xml`. + +```bash +$ fd -I -H -E node_modules 'sitemap.*.xml' +``` + +After familiarizing myself with a few flags, I'm able to take full advantage of +`fd`.