TIL exclude directories in grep and ripgrep

$ man grep
        Skip any command-line file with a name suffix that matches the
        pattern GLOB, using wildcard matching; a name suffix is either
        the whole name, or a trailing part that starts with a non-slash
        character immediately after a slash (/) in the name.  When
        searching recursively, skip any subfile whose base name matches
        GLOB; the base name is the part after the last slash.  A pattern
        can use *, ?, and [...] as wildcards, and \ to quote a wildcard
        or backslash character literally.
        Skip files whose base name matches any of the file-name globs
        read from FILE (using wildcard matching as described under
        Skip any command-line directory with a name suffix that matches
        the pattern GLOB.  When searching recursively, skip any
        subdirectory whose base name matches GLOB.  Ignore any redundant
        trailing slashes in GLOB.

So to exclude a directory with the name test for example:

grep -r --exclude-dir=test something

I expected that ripgrep has similar options, but in that case it doesn't.

rg --help

-g, --glob <GLOB>... Include or exclude files and directories for searching that match the given glob. This always overrides any other ignore logic. Multiple glob flags may be used. Globbing rules match .gitignore globs. Precede a glob with a ! to exclude it.

So use the --glob option for that:

rg --glob='^test/' something

Hozzászóláshoz a Disqus szolgáltatását használom, korábbi vélemények elovlasásához és új hozzászólás írásához engedélyezd a Disqus-tól származó JavaScripteteket.