---
title: "Find files"
description: "List, glob, grep and read the files in a drive, from an agent, the CLI, Python or the API."
canonical_url: "https://docs.flashdrive.space/getting-started/find-files"
---
# Find files

> List, glob, grep and read the files in a drive, from an agent, the CLI, Python or the API.

Agents and people find things in a drive the way they would in a local folder: list a folder, match paths with a glob, grep for a pattern, then read the lines or bytes they need. Every surface offers the same four moves.

## At a glance

<table>
<thead>
  <tr>
    <th>
      Task
    </th>
    
    <th>
      MCP tool
    </th>
    
    <th>
      <code>
        flashdrive
      </code>
      
       command
    </th>
    
    <th>
      Python SDK
    </th>
    
    <th>
      REST API
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      List files
    </td>
    
    <td>
      <code>
        list_files
      </code>
    </td>
    
    <td>
      <code>
        flashdrive file list
      </code>
    </td>
    
    <td>
      <code>
        client.files.list()
      </code>
    </td>
    
    <td>
      <code>
        GET /v1/drives/{drive_id}/files
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      List folders
    </td>
    
    <td>
      <code>
        list_folders
      </code>
    </td>
    
    <td>
      <code>
        flashdrive folder list
      </code>
    </td>
    
    <td>
      <code>
        client.folders.list()
      </code>
    </td>
    
    <td>
      <code>
        GET /v1/drives/{drive_id}/folders
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Match paths
    </td>
    
    <td>
      <code>
        glob_files
      </code>
    </td>
    
    <td>
      <code>
        flashdrive file glob PATTERN
      </code>
    </td>
    
    <td>
      <code>
        client.files.glob(pattern)
      </code>
    </td>
    
    <td>
      <code>
        GET /v1/drives/{drive_id}/files?pattern=...
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Grep text
    </td>
    
    <td>
      <code>
        grep
      </code>
    </td>
    
    <td>
      <code>
        flashdrive grep PATTERN
      </code>
    </td>
    
    <td>
      <code>
        client.files.grep(pattern)
      </code>
    </td>
    
    <td>
      <code>
        POST /v1/drives/{drive_id}/full-text-search
      </code>
      
       with <code>
        "mode": "regex"
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Read lines
    </td>
    
    <td>
      <code>
        read_file
      </code>
    </td>
    
    <td>
      <code>
        flashdrive file read DOCUMENT_ID --start-line N --line-count N
      </code>
    </td>
    
    <td>
      <code>
        client.files.read(document_id, start_line=..., line_count=...)
      </code>
    </td>
    
    <td>
      <code>
        GET /v1/drives/{drive_id}/documents/{document_id}/text
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Read a text byte range
    </td>
    
    <td>
      <code>
        read_file
      </code>
      
       with <code>
        offset
      </code>
      
       and <code>
        length
      </code>
    </td>
    
    <td>
      <code>
        flashdrive file read DOCUMENT_ID --offset N --length N
      </code>
    </td>
    
    <td>
      <code>
        client.files.read(document_id, offset=..., length=...)
      </code>
    </td>
    
    <td>
      Same route, with <code>
        offset
      </code>
      
       and <code>
        length
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      Read original bytes
    </td>
    
    <td>
      <code>
        read_bytes
      </code>
    </td>
    
    <td>
      <code>
        flashdrive file cat DOCUMENT_ID --bytes A-B
      </code>
    </td>
    
    <td>
      <code>
        client.files.read_bytes(document_id, offset, length)
      </code>
    </td>
    
    <td>
      A file link with a <code>
        Range
      </code>
      
       header
    </td>
  </tr>
  
  <tr>
    <td>
      Stream a large file
    </td>
    
    <td>
      <code>
        get_file
      </code>
    </td>
    
    <td>
      <code>
        flashdrive file link DOCUMENT_ID
      </code>
    </td>
    
    <td>
      <code>
        client.files.link(document_id)
      </code>
    </td>
    
    <td>
      <code>
        POST /v1/drives/{drive_id}/documents/{document_id}/source/link
      </code>
    </td>
  </tr>
</tbody>
</table>

In the SDK, `client` is a `Flashdrive` client. Every call works on the client's drive unless you pass `drive_id`. The CLI works on the drive you selected with `flashdrive drive use`, or the one you name with `--drive`.

## List files and folders

A listing returns each file's `path`, `filename`, `format`, `size_bytes`, `revision` and `document_id`. Keep the `document_id`: reads and changes use it.

```sh
flashdrive file list --limit 100
flashdrive file list --folder FOLDER_ID
flashdrive file list --all
```

Pass a folder ID to list one folder, or `root` for the files outside any folder. A page holds up to 100 files (50 by default). When `next_cursor` is set, call again with it, or use `--all` in the CLI to fetch every page.

## Match paths with a glob

```sh
flashdrive file glob '**/*.md'
```

```python
page = client.files.glob("reports/*.pdf")
for f in page.files:
    print(f.path, f.document_id)
```

<table>
<thead>
  <tr>
    <th>
      Pattern
    </th>
    
    <th>
      Matches
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        **/*.md
      </code>
    </td>
    
    <td>
      Markdown files in any folder
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        docs/*.txt
      </code>
    </td>
    
    <td>
      Text files directly in <code>
        docs/
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        *.{md,txt}
      </code>
    </td>
    
    <td>
      Markdown and text files at any depth
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        report-202?.pdf
      </code>
    </td>
    
    <td>
      <code>
        report-2024.pdf
      </code>
      
      , <code>
        report-2025.pdf
      </code>
      
       and so on
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        [a-c]*.log
      </code>
    </td>
    
    <td>
      Log files whose names start with a, b or c
    </td>
  </tr>
</tbody>
</table>

A pattern without `/` matches file names at any depth. On a very large drive a glob is read in parts: when `complete` is `false` or `next_cursor` is set, continue with `next_cursor` to cover the rest.

To find recovery copies, glob for `'* (conflict *'`.

## Grep across a drive

`grep` finds lines that match a regular expression across a drive's text, like `grep` or `ripgrep`. Each result has the file path, `document_id`, line number and the matching line.

```sh
flashdrive grep 'TODO\(\w+\)' --glob '**/*.md' -C 2
```

```python
page = client.files.grep(r"^## .*install", glob="docs/**", context_lines=1)
for m in page.results:
    print(m.path, m.start_line, m.text)
```

- Matching is case-insensitive unless you set `case_sensitive` (`--case-sensitive`).
- `context_lines` (`-C`) adds 0 to 5 lines before and after each match.
- Narrow the files with `glob` (`--glob`) or a folder.
- The pattern engine runs in linear time, so it has no look-around or backreferences.
- Results come in file order, up to 100 per page (20 by default). When `next_cursor` is set, call again with it. When `complete` is `false`, the call stopped before covering the whole drive; continue with `next_cursor`. When `complete` is `false` and `next_cursor` is null, the index is still catching up with recent changes: every result returned is current, and a later call may find more.

Grep reads the text of PDF, Word (`.docx`), plain text (`.txt`) and Markdown (`.md`) files. Other files are stored as they are and have no text to match; find them by path, and read their bytes as described below.

Grep is on for every drive, and there is no setting to turn it off. If grep answers `full_text_search_off`, keyword and pattern search is unavailable for that drive: contact [support](mailto:support@evokoa.com) with the request ID. Listing, globbing and reading files still work.

## Read a file by line or byte range

Read only what you need. By lines, give the first line (counting from 1) and how many lines to read, up to 2,000 (500 by default):

```sh
flashdrive file read DOCUMENT_ID --start-line 120 --line-count 40
```

By bytes of the file's text, give an offset (counting from 0) and a length of up to 32,768 bytes:

```python
part = client.files.read(document_id, offset=0, length=32768)
print(part.text, part.next_offset)
```

The answer includes `next_line` or `next_offset` to continue, and is `null` at the end of the file. Pass the `revision` from an earlier read to be told if the file has changed since.

To quote a grep match, read the lines around the line number grep returned.

## Read the original bytes

For headers and indexes inside binary files, such as a Parquet footer, a zip directory or an MP4 box, read raw bytes of the original file:

- MCP: `read_bytes` returns up to 32,768 bytes, base64-encoded, from an offset.
- CLI: `flashdrive file cat DOCUMENT_ID --bytes 0-1023` prints a range: `A-B` (inclusive), `A-` or `-N` (the last N bytes), at most 64 MiB.
- SDK: `client.files.read_bytes(document_id, offset, length)` returns up to 64 MiB.

## Stream a large file to a program

A file link is a short-lived URL for one file. It needs no `Authorization` header and answers HTTP `Range` requests, so programs such as `curl`, `ffmpeg`, a video player or DuckDB can seek and stream without downloading the whole file.

```sh
flashdrive file link DOCUMENT_ID --ttl 900
```

A CLI link lasts from 60 to 3,600 seconds (900 by default). Treat the link as a secret until it expires, and never paste it into a file or a prompt.

## On a mounted drive

On macOS or Linux, [mount the drive](https://docs.flashdrive.space/cli/mount-and-sync) and use the tools you already have: `ls`, `find`, `rg`, `grep`, `head`, an editor or your own scripts. They work on every file, whatever its type. A mount downloads only the parts of each file that a program reads, so a tool that reads every file in a large drive downloads every file it reads; prefer the drive's own `glob` and `grep` for a first pass, then open the files they point to.

## Keep up with changes

To follow what changed in a drive since your last look, use the change feed: `GET /v1/drives/{drive_id}/changes` in the API, or `client.drives.changes(cursor=...)` in the SDK. Take a cursor first, list the drive, then ask for changes since that cursor. See the [content API](https://docs.flashdrive.space/reference/content-api).

See also the [MCP tools](https://docs.flashdrive.space/mcp/tools), [CLI commands](https://docs.flashdrive.space/cli/commands) and [SDK file methods](https://docs.flashdrive.space/sdk/files).


## Sitemap

See the full [sitemap](https://docs.flashdrive.space/sitemap.md) for all pages.
