Built-in tools›Files and search
Search content
grep- Group
- Files and search
- Turned on by
- Its own switch on the Tools page of Conversation settings.
- Approval
- Not reviewed: runs without asking, within the limits on this page.
- Profile key
tool.grep.description
Searches file contents with a regular expression and reports where it matches: the files, the matching lines, or a count per file.
Matching works one line at a time, so a pattern cannot span lines. It is case-sensitive unless the model passes case_sensitive: false. The syntax has no look-around and no backreferences.
output_mode picks the answer:
files_with_matches, the default: the files with a match, newest first.content: each matching line with its file and line number.context,beforeandafteradd 0 to 20 lines around every match.count: the number of matching lines in each file, and the totals.
glob, such as *.rs or src/**/*.tsx, limits the search to the files it matches.
Limits
- Binary files and links are skipped. A text file is searched whatever its size.
- A call returns 250 results by default and at most 1,000 with
limit;offsetfetches the next page. - In
contentmode, each line shown, context lines included, is cut at 500 characters. - A result over 20,000 characters is saved to a file in Mewrk's app-data folder. The model gets the first 2,000 characters and the file's path.
Good to know
- It searches what Git would show: tracked files, and untracked files Git does not ignore. Outside a Git repository, dependency and build folders such as
node_modulesandtargetare skipped. A single file named aspathis always searched. - On a WSL or SSH machine whose
grephas no--nulloption (BusyBox, for one), a call that asks for context gets none, and the result says so. - You can change a recorded
grepcall in the timeline and run it again with Rerun.
Parameters
| Parameter | Type | Details |
|---|---|---|
pattern requiredSearch pattern | string | — |
afterLines after | integer | content mode only: lines of context to show after each match, 0 to 20. |
beforeLines before | integer | content mode only: lines of context to show before each match, 0 to 20. |
case_sensitiveCase sensitive | boolean | Default true |
contextContext | integer | content mode only: lines of context to show before and after each match, 0 to 20. |
globFile glob | string | Only search files whose path matches this glob, such as .rs or src/**/.tsx. |
limitLimit | integer | Most results of the chosen mode to return: 250 by default, at most 1,000. Default 250 |
offsetOffset | integer | Results of the chosen mode to skip first, to fetch the next page. Default 0 |
output_modeOutput mode | string | files_with_matches (default) lists the files that match; content lists the matching lines; count gives the number of matching lines per file."files_with_matches" "content" "count"Default "files_with_matches" |
pathPath | string | Default "." |