LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Agent
  • Middleware
  • Backends
  • Sandboxes
  • Skills
  • Subagents
  • Configuration
  • Types
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
  • Vitest
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewAgentMiddlewareBackendsSandboxesSkillsSubagentsConfigurationTypes
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
Vitest
Language
Theme
JavaScriptdeepagentsbackendsgrepSearchFiles
Function●Since v1.4

grepSearchFiles

Search file contents for literal text pattern.

Performs literal text search.

Copy
grepSearchFiles(
  files: Record<string, FileData>,
  pattern: string,
  path: string | null = null,
  glob: string | null = null,
  outputMode: "content" | "files_with_matches" | "count" = "files_with_matches"
): string

Parameters

NameTypeDescription
files*Record<string, FileData>

Dictionary of file paths to FileData

pattern*string

Literal text to search for

pathstring | null
Default:null

Base path to search from

globstring | null
Default:null

Optional glob pattern to filter files (e.g., "*.py")

outputMode"content" | "files_with_matches" | "count"
Default:"files_with_matches"

Output format - "files_with_matches", "content", or "count"

Example

Copy
const files = {"/file.py": FileData({content: ["import os", "print('hi')"], ...})};
grepSearchFiles(files, "import", "/");
// Returns: "/file.py" (with output_mode="files_with_matches")
View source on GitHub