# Install topfew with Homebrew, MacPorts, Nix

Finds the field values which appear most often in a stream of records. Version 2.0.0 via Homebrew; verified from local package data.

## Install

```sh
sudo av install brew:topfew
```

Additional install commands:

### macOS

- Homebrew (100%):

```sh
brew install topfew
```

  Evidence: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install topfew
```

  Evidence: MacPorts ports tree: textproc/topfew/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- Nix (92%):

```sh
nix profile install nixpkgs#topfew
```

  Evidence: nixpkgs package indexes: pkgs/by-name/to/topfew/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

## Package facts

- **Package key:** brew:topfew
- **Package manager:** Homebrew
- **Package manager page:** <https://formulae.brew.sh/formula/topfew>
- **Version:** 2.0.0
- **Source summary:** Finds the field values which appear most often in a stream of records
- **Homepage:** <https://github.com/timbray/topfew>
- **Repository:** <https://github.com/timbray/topfew>
- **Upstream docs:** <https://github.com/timbray/topfew#readme>
- **License:** GPL-3.0-or-later
- **Source archive:** <https://github.com/timbray/topfew/archive/refs/tags/v2.0.0.tar.gz>
- **Generated:** 2026-07-08T18:08:21+00:00

## Executables

- topfew (cli)
- topfew (alias)

## Build dependencies

- go

## Install behavior

- Post-install hook: not defined
- Bottle: available on arm64_linux, arm64_monterey, arm64_sequoia, arm64_sonoma, arm64_tahoe, arm64_ventura, monterey, sonoma, ventura, x86_64_linux

## Freshness

- Page generated: 2026-07-08
- Package-manager version: 2.0.0
- Local data: ok
- Upstream repository: https://github.com/timbray/topfew
- Upstream latest detected: v2.0.0 (current)
- info: No package-manager update timestamp was available.
## Project history and usage

topfew is a Go command-line utility for finding the most frequent records or field combinations in text streams and files. It packages a familiar Unix analysis pattern into a faster, purpose-built binary.

### Project history

Tim Bray created Topfew as a utility for counting common values in streams of records, with the README crediting his version 0.1 and later work toward 1.0 to ideas from Dirkjan Ochtman and Simon Fell. The project reached a documented 1.0 release in April 2024, and the current README describes release 2.0.

The design is explicitly close to traditional shell composition: the README states that its result can be duplicated with awk, grep, sed, sort, uniq, and head, but argues that Topfew is for cases where performance matters on large inputs. The examples are package-nerd friendly: Apache logs, quoted fields, grep/vgrep filters, sed-style cleanups, and multi-threaded file processing.

### Adoption history

topfew is niche but packaged beyond its source repository. The input package metadata lists Homebrew, MacPorts, and Nix package names, matching its role as a small single-purpose CLI that is useful enough to show up in Unix package collections.

### How it is used

The basic form is `topfew --fields 1 access_log`, which finds the most common first field in an Apache log. More advanced use combines field selection, regex separators, grep and inverse-grep filters, sed-style transformations, quoted-field parsing, output limits, and worker counts.

### Why package nerds care

topfew matters to package nerds because it is a performance-oriented replacement for a shell pipeline they already know. It is the sort of small binary people install from Homebrew or Nix when a log-analysis one-liner becomes too slow or too hard to repeat.

### Timeline

- 2020: Author blog posts describe Topfew as a small utility replacing the `sort | uniq -c | sort -rn | head` pattern.
- 2024: Tim Bray announced Topfew 1.0.
- Current: README describes release 2.0 and documents Homebrew-friendly CLI usage.

### Related projects

- awk, grep, sed, sort, uniq, head, Apache httpd logs, Go runtime.

### Sources

- <https://github.com/timbray/topfew#readme>
- <https://www.tbray.org/ongoing/When/202x/2020/07/01/More-Topfew-Fun>
- <https://www.tbray.org/ongoing/When/202x/2024/04/12/Topfew-release>
- source_facts.package-manager


## Security Notes

broad file, network, media, or database tool signal.

- **Geiger risk:** blue / medium
- broad file, network, media, or database tool signal

## Source Database Details

- **Source Database:** Homebrew formula API
- **Tap:** homebrew/core
- **Full Name:** topfew
- **Version Scheme:** 0
- **Revision:** 0
- **Bottle Stable Root URL:** <https://ghcr.io/v2/homebrew/core>
- **Deprecated:** no
- **Disabled:** no
- **Keg Only:** no
- **URL Keys:** stable

## Other Package-Manager Records

- Nix - topfew: normalized package name match | nixpkgs package indexes: pkgs/by-name/to/topfew/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- MacPorts - topfew: normalized package name match | MacPorts ports tree: textproc/topfew/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1


## Related links

- [Source-control packages](https://www.automicvault.com/pkg/source-control-tools/) - Belongs to a source-control command family.
- [Secret-risk packages](https://www.automicvault.com/pkg/secret-risk-packages/) - Has protected-tool coverage, approval-gate, or non-low Geiger security signals.
- [Terminal utility packages](https://www.automicvault.com/pkg/terminal-utilities/) - Matched terminal and command-line workflow metadata.
- [Text processing packages](https://www.automicvault.com/pkg/text-processing-tools/) - Matched text, document, or structured-data processing metadata.
- [go](https://www.automicvault.com/pkg/brew/go/) - Build dependency declared by Homebrew.
- [datamash](https://www.automicvault.com/pkg/brew/datamash/) - Shares av.db curated category or tags: cli, data, statistics, text-processing.
- [apache-flink](https://www.automicvault.com/pkg/brew/apache-flink/) - Shares av.db curated category or tags: cli, data, stream-processing.
- [benthos](https://www.automicvault.com/pkg/brew/benthos/) - Shares av.db curated category or tags: cli, data, stream-processing.
- [chadwick](https://www.automicvault.com/pkg/brew/chadwick/) - Shares av.db curated category or tags: cli, data, statistics.
- [ffe](https://www.automicvault.com/pkg/brew/ffe/) - Shares av.db curated category or tags: cli, data, text-processing.
- [nifi](https://www.automicvault.com/pkg/brew/nifi/) - Shares av.db curated category or tags: cli, data, stream-processing.
- [sentencepiece](https://www.automicvault.com/pkg/brew/sentencepiece/) - Shares av.db curated category or tags: cli, data, text-processing.
- [storm](https://www.automicvault.com/pkg/brew/storm/) - Shares av.db curated category or tags: cli, data, stream-processing.
- [JSONStream](https://www.automicvault.com/pkg/npm/jsonstream/) - Local package facts share a topical domain. Shared terms: cli, data, processing, stream, stream-processing.

## Combined YAML source

View the package source record on GitHub. [combined/topfew.yml](https://github.com/automic-vault/db/blob/main/combined/topfew.yml)


## Sources

- Nucleus package database
- Geiger risk classifier
- package-page enrichment
- curated package history
- package version freshness
- av.db category and tag curation
- package relationship graph
- external package-manager database matches
- cross-ecosystem install command graph
