## Grep File

`RetrievalGrepPage beta().retrieval().grep(RetrievalGrepParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

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

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

### Parameters

- `RetrievalGrepParams params`

  - `Optional<String> organizationId`

  - `Optional<String> projectId`

  - `String fileId`

    ID of the file to grep.

  - `String indexId`

    ID of the index the file belongs to.

  - `String pattern`

    Regex pattern to search for.

  - `Optional<Long> contextChars`

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

  - `Optional<Long> pageSize`

    The maximum number of items to return. The service may return fewer than this value. If unspecified, a default page size will be used. The maximum value is typically 1000; values above this will be coerced to the maximum.

  - `Optional<String> pageToken`

    A page token, received from a previous list call. Provide this to retrieve the subsequent page.

### Returns

- `class RetrievalGrepResponse:`

  A single grep match within a file.

  - `String content`

    Matched text content.

  - `long endChar`

    End character offset of the match.

  - `long startChar`

    Start character offset of the match.

### Example

```java
package com.llamacloud_prod.api.example;

import com.llamacloud_prod.api.client.LlamaCloudClient;
import com.llamacloud_prod.api.client.okhttp.LlamaCloudOkHttpClient;
import com.llamacloud_prod.api.models.beta.retrieval.RetrievalGrepPage;
import com.llamacloud_prod.api.models.beta.retrieval.RetrievalGrepParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        RetrievalGrepParams params = RetrievalGrepParams.builder()
            .fileId("file_id")
            .indexId("idx-abc123")
            .pattern("revenue|profit")
            .build();
        RetrievalGrepPage page = client.beta().retrieval().grep(params);
    }
}
```

#### Response

```json
{
  "items": [
    {
      "content": "content",
      "end_char": 0,
      "start_char": 0
    }
  ],
  "next_page_token": "next_page_token",
  "total_size": 0
}
```
