## Grep File

`client.Beta.Retrieval.Grep(ctx, params) (*BetaRetrievalGrepResponse, error)`

**post** `/api/v1/retrieval/files/grep`

Grep within a file's parsed content using a regex pattern.

### Parameters

- `params BetaRetrievalGrepParams`

  - `FileID param.Field[string]`

    Body param: ID of the file to grep.

  - `IndexID param.Field[string]`

    Body param: ID of the index the file belongs to.

  - `Pattern param.Field[string]`

    Body param: Regex pattern to search for.

  - `OrganizationID param.Field[string]`

    Query param

  - `ProjectID param.Field[string]`

    Query param

  - `ContextChars param.Field[int64]`

    Body param: Number of characters of context to include before and after the matched pattern in the content field of the response

  - `Limit param.Field[int64]`

    Body param: Maximum number of matches to return.

### Returns

- `type BetaRetrievalGrepResponse struct{…}`

  Grep results for a file.

  - `Matches []BetaRetrievalGrepResponseMatch`

    Regex matches found in the file.

    - `Content string`

      Matched text content.

    - `EndChar int64`

      End character offset of the match.

    - `StartChar int64`

      Start character offset of the match.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/llamacloud-prod-go"
  "github.com/stainless-sdks/llamacloud-prod-go/option"
)

func main() {
  client := llamacloudprod.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.Beta.Retrieval.Grep(context.TODO(), llamacloudprod.BetaRetrievalGrepParams{
    FileID: "file_id",
    IndexID: "idx-abc123",
    Pattern: "revenue|profit",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Matches)
}
```

#### Response

```json
{
  "matches": [
    {
      "content": "content",
      "end_char": 0,
      "start_char": 0
    }
  ]
}
```
