grep
Search for text patterns in files using regular expressions. Specify directory, pattern, and optional exclusion criteria. Returns matches with file path, line number, and matching line, respecting .gitignore and directory restrictions.
Instructions
Search for text patterns inside files using regular expressions.
Args: dir (str): Directory to search in (absolute or relative to allowed directories) pattern (str): Regular expression pattern to search for in file contents exclude (str, optional): File pattern to exclude from search
Returns: str: Newline-separated matches in format 'path: line', or error message if failed
Note: - Directory must be within allowed directory roots - Searches recursively through subdirectories - Only searches UTF-8 text files - Respects .gitignore files and skips common lock files - Each match shows file path, line number, and the matching line - Uses Python regular expression syntax
Input Schema
Name | Required | Description | Default |
---|---|---|---|
dir | Yes | ||
exclude | No | ||
pattern | Yes |