Skip to content

grep

Search file contents for lines matching a regular expression.

Category: Read-only

Parameters

pattern (required)
Java regex pattern (java.util.regex syntax) to search for in file contents.
path (optional)
The directory to search. Defaults to the current working directory.
include (optional)

Java glob pattern restricting which files are searched (e.g. *.kt, **/*.json). Uses the same syntax as glob. If omitted, all files in the search root are searched.

Note

**/*.ext requires at least one directory separator before the filename. Use *.ext to match files directly in the search root.

Output

Matches grouped by file, with each file sorted by modification time (most recent first) and matches within each file listed by line number:

Found 3 matches

/path/to/Foo.kt:
 Line 12: val name: String
 Line 45: fun name(): String

/path/to/Bar.kt:
 Line 7: val name = "default"

Returns No matches found if nothing matches. Unreadable and binary files are silently skipped. Results are capped at 100 matches; a truncation note is appended when the limit is reached. Lines longer than 2000 characters are truncated.