---
title: "af search"
description: "Search main's files with a regular expression"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.forge.workreef.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# af search

<!-- Generated by tools/gen-reference.mjs from `af search --help`. Change the help text in crates/atoll-forge-cli/src/main.rs, then run `npm run gen:reference`. -->

Prints each matching line as `path:line:text`, searching only the files you may read. `^` and `$` match at the start and end of each line. With only --file, prints the paths that match it.

## Usage

```text
af search [OPTIONS] [PATTERN]
```

## Arguments

- `[PATTERN]`

  Regular expression to search for, in Rust `regex` syntax

## Options

- `-f, --file <FILE>`

  Search only files whose path matches this regular expression

- `-n, --limit <LIMIT>`

  Maximum number of files to return

  Default: `20`

- `--lines <LINES>`

  Maximum number of matching lines to return from each file

  Default: `20`

## Global options

Every `af` command also takes the [global options](https://docs.forge.workreef.dev/reference/af/#global-options).

## Examples

```sh
af search 'fn main'                  Lines matching `fn main` in any file
af search 'TODO' -f '\.rs$'          Lines matching `TODO` in Rust files
af search -f '(^|/)Cargo\.toml$'     Paths of all Cargo.toml files
```

Source: https://docs.forge.workreef.dev/reference/af/search/index.mdx
