mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Ignore A Directory During ripgrep Search as a Unix TIL
This commit is contained in:
@@ -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).
|
||||
|
||||
_1280 TILs and counting..._
|
||||
_1281 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -1250,6 +1250,7 @@ _1280 TILs and counting..._
|
||||
- [Grep For Files With Multiple Matches](unix/grep-for-files-with-multiple-matches.md)
|
||||
- [Grep For Multiple Patterns](unix/grep-for-multiple-patterns.md)
|
||||
- [Hexdump A Compiled File](unix/hexdump-a-compiled-file.md)
|
||||
- [Ignore A Directory During ripgrep Search](unix/ignore-a-directory-during-ripgrep-search.md)
|
||||
- [Ignore The Alias When Running A Command](unix/ignore-the-alias-when-running-a-command.md)
|
||||
- [Interactively Browse Available Node Versions](unix/interactively-browse-availabile-node-versions.md)
|
||||
- [Jump To The Ends Of Your Shell History](unix/jump-to-the-ends-of-your-shell-history.md)
|
||||
|
||||
25
unix/ignore-a-directory-during-ripgrep-search.md
Normal file
25
unix/ignore-a-directory-during-ripgrep-search.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Ignore A Directory During ripgrep Search
|
||||
|
||||
When searching for patterns in project with many directories and files using
|
||||
`ripgrep`, it is easy to end up with an overwhelming amount of results. If you
|
||||
know that a certain directory of results isn't of interest, you can exclude
|
||||
that directory. This is done with the glob flag (`-g`) and the inverse (`!`)
|
||||
operator.
|
||||
|
||||
Here is an example of just using the `-g` flag. This will find all matches of
|
||||
the pattern within that directory.
|
||||
|
||||
```bash
|
||||
$ rg 'some pattern' -g 'dir/'
|
||||
```
|
||||
|
||||
To instead exclude that directory and by extension search everywhere else, we
|
||||
can invert the glob match with `!`.
|
||||
|
||||
```bash
|
||||
$ rg 'some pattern' -g '!dir/'
|
||||
```
|
||||
|
||||
This says, find the pattern anywhere that is not in `dir/`.
|
||||
|
||||
[source](https://blog.wxm.be/2020/11/08/ignore-folder-in-ripgrep.html)
|
||||
Reference in New Issue
Block a user