grep
Search file contents with regular expressions to find matching lines, filter by glob patterns, and return content, file paths, or match counts.
Instructions
Searches file contents using regular expressions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| glob | No | The glob pattern to filter files to be searched (e.g., `*.{ts,tsx}` or `src/**/*.rs`). Extremely useful for narrowing down searches and improving speed. Defaults to `null` if not specified. | |
| path | No | The directory or file to search in. Defaults to empty if not specified. | |
| limit | No | The maximum number of lines to return. Useful for preventing token overflow when a pattern matches thousands of files/lines. Defaults to `100` if not specified. | |
| offset | No | The number of lines to skip. Used in combination with limit to paginate through large sets of matching lines. Defaults to `0` if not specified. | |
| pattern | Yes | The regular expression pattern to search for in file contents. Uses standard regex syntax. IMPORTANT: Remember to escape literal characters (e.g., `interface\{`). | |
| multiline | No | Whether to enable multiline mode where `.` matches newlines, `^` and `$` match line boundaries, and patterns can span multiple lines. Defaults to `false` if not specified. | |
| output_mode | No | The output mode: `content` (matching lines), `files_with_matches` (paths only), or `count` (match counts per file). Defaults to `content` if not specified. | |
| after_context | No | The number of lines to show after each match to provide context. Requires `output_mode` to be `content` or omitted. Ignored otherwise. Defaults to `0` if not specified. | |
| before_context | No | The number of lines to show before each match to provide context. Requires `output_mode` to be `content` or omitted. Ignored otherwise. Defaults to `0` if not specified. | |
| show_line_numbers | No | Whether to show line numbers in the output. Requires `output_mode` to be `content` or omitted. Ignored otherwise. Defaults to `true` if not specified. |