• Searches for content within a single file

    Parameters

    • filePath: string

      Path to the file to search

    • searchPattern: string | RegExp

      String or regex pattern to search for

    • options: SearchOptions = {}

      Search options

    Returns Promise<OperationResult<SearchMatch[]>>

    OperationResult containing array of SearchMatch objects

    const result = await searchInFile('/path/to/file.txt', 'function', {
    includeLineNumbers: true,
    contextLines: 2
    });
    if (result.success) {
    result.data.forEach(match => {
    console.log(`Found at line ${match.lineNumber}: ${match.line}`);
    });
    }