Glob Pattern Guide with auditor

-i (include) and -e (exclude) take glob patterns. Enclose each pattern in double quotes, so the shell does not expand it:

auditor hash input_path -i "**/*.txt"

Patterns are matched against the path of each file relative to input_path, with / as separator (also on Windows). For input_path/src/app.json that is src/app.json. The folders above input_path never take part: **/test/** selects the files of a test folder inside input_path, even if input_path itself is inside a folder named test.

-i keeps only the files that match; -e leaves out the files that match. Both accept several patterns (-i "*.doc" "*.xls"), and can be used together: -e is applied to what -i selected. check applies the same patterns to the files listed in the <Audit_FullList>.

Below, the rules to write glob patterns (every example is verified by auditor's tests):

Basic Wildcards

* - Match any characters (except /)

? - Match exactly one character

** - Match any number of directories (also none)

Character Classes

[...] - Match one character from set

[!...] - Match one character NOT in set

Alternation

{a,b,c} - Match any of the alternatives

Common Examples

# Configuration files (directly in input_path)
*.{json,yaml,toml,ini}

# Rust files under src/
src/**/*.rs

# All documentation, at any depth
**/*.{md,txt,rst}

# Test files
{tests,test}/**/*.rs
**/*_test.rs
**/test_*.rs

# Images
**/*.{png,jpg,jpeg,gif,svg,webp}

# Nested package files
**/Cargo.toml
**/package.json

# Everything in a specific directory
assets/**

# Files at specific depth
*/*.rs      # One folder below input_path
*/*/*.rs    # Two folders below input_path

Excluding files: use -e

There is no negation inside a pattern: a ! starting a pattern or an alternative (!*.tmp, {**/*.rs,!target/**}) is refused with an error. Put what you want to leave out in -e. ([!...], one character not in a set, is not negation and works.)

# All Rust files except those in target/
auditor hash input_path -i "**/*.rs" -e "target/**"

# Everything except hidden files and hidden folders (at any depth)
auditor hash input_path -e "**/.*" "**/.*/**"

**/.* alone leaves out hidden files, but not the files inside a hidden folder: **/.*/** covers those.

Upper and lower case

Matching follows the operating system: on Windows it ignores case (*.TXT matches a.txt), on Linux and macOS it does not. To get the same result everywhere:

Tips