ripgrep (rg) is built to search inside files, but sometimes you just want to find files by name. The same job as find or Get-ChildItem -Filter.

There are two clean ways to do it.

Method 1: --files with -g (glob)

rg --files -g 'Launch-VsDevShell.ps1'
  • --files tells ripgrep to list every file it would search — no content search happens at all
  • -g (or --glob) filters that list to filenames matching the pattern

This is the clearest way to express “find files named X”. The glob supports wildcards:

# Find all .ps1 files
rg --files -g '*.ps1'

# Find any file named exactly 'config.toml'
rg --files -g 'config.toml'

Method 2: . pattern with -l

rg . -g 'Launch-VsDevShell.ps1' -l --no-messages
  • . is a regex matching any single character — it serves as a dummy “find files that aren’t empty” pattern, since ripgrep requires at least one pattern
  • -g 'Launch-VsDevShell.ps1' restricts which files are searched
  • -l (or --files-with-matches) prints only the file paths, not the matching lines
  • --no-messages suppresses “permission denied” errors

This approach is common in examples online and works well, though --files -g is more semantically precise.

Narrow the search by directory

Both methods search your current working directory recursively. To search a specific directory, either cd into it first or pass a path:

rg --files -g 'Launch-VsDevShell.ps1' 'C:\Program Files'

You can also add a second -g flag to filter by a directory pattern. Multiple globs are ANDed:

# Only look inside directories matching 'Program Files*'
rg . -g 'Launch-VsDevShell.ps1' -g 'Program Files*\' -l --no-messages

Starting closer to the target directory is usually faster than filtering after the fact:

cd 'C:\Program Files\Microsoft Visual Studio'
rg --files -g 'Launch-VsDevShell.ps1'

Comparison

Goal Command
List all files ripgrep would search rg --files
Find files matching a name pattern rg --files -g 'pattern'
Find non-empty files matching a name rg . -g 'pattern' -l --no-messages
Find files in a specific directory rg --files -g 'pattern' path/to/dir