# Install grep with Homebrew, apk, chocolatey, apt, dnf, MacPorts, pacman, scoop, zypper

GNU grep, egrep and fgrep. Version 3.12 via Homebrew; verified from local package data.

## Install

```sh
sudo av install brew:grep
```

Additional install commands:

### macOS

- Homebrew (100%):

```sh
brew install grep
```

  Evidence: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install grep
```

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

### Linux

- apk (92%):

```sh
sudo apk add grep
```

  Evidence: Alpine Linux edge package indexes: grep from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz

- Debian apt (92%):

```sh
sudo apt install grep
```

  Evidence: Debian stable package indexes: grep from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

- dnf (92%):

```sh
sudo dnf install grep
```

  Evidence: Fedora Rawhide package metadata: grep from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/e5ca8ce900cd68f5419e1c39ae517343100b306336cbaeb70a3c153121d95094-primary.xml.zst

- pacman (92%):

```sh
sudo pacman -S grep
```

  Evidence: Arch Linux sync databases: grep from https://geo.mirror.pkgbuild.com/core/os/x86_64/core.db.tar.gz

- zypper (92%):

```sh
sudo zypper install grep
```

  Evidence: openSUSE Tumbleweed package metadata: grep from https://download.opensuse.org/tumbleweed/repo/oss/repodata/be8d3611d25469107f32075a1697e69ec57a2b850b42348a658cc671ad5ec2b50760d02c3e59524d50da9a11d5be799bdaffba2e166e8ca8858512e3c0bd665d-primary.xml.zst

### Windows

- Chocolatey (92%):

```sh
choco install grep
```

  Evidence: Chocolatey community package catalog: grep from http://community.chocolatey.org/api/v2/Packages?$filter=IsLatestVersion&$select=Id&$top=1000&$skiptoken='11','gpg4win-vanilla'

- Scoop (92%):

```sh
scoop install main/grep
```

  Evidence: Scoop official bucket manifest trees: bucket/grep.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1

## Package facts

- **Package key:** brew:grep
- **Package manager:** Homebrew
- **Package manager page:** <https://formulae.brew.sh/formula/grep>
- **Version:** 3.12
- **Source summary:** GNU grep, egrep and fgrep
- **Homepage:** <https://www.gnu.org/software/grep/>
- **Repository:** <https://git.savannah.gnu.org/git/grep.git>
- **Upstream docs:** <https://www.gnu.org/software/grep/manual>
- **License:** GPL-3.0-or-later
- **Source archive:** <https://ftpmirror.gnu.org/gnu/grep/grep-3.12.tar.xz>
- **Generated:** 2026-07-08T07:18:31+00:00

## Executables

- egrep (cli)
- fgrep (cli)
- grep (cli)
- egrep (alias)
- fgrep (alias)
- grep (alias)

## Dependencies

- pcre2

## Build dependencies

- pkgconf

## Install behavior

- Post-install hook: not defined
- Caveats: All commands have been installed with the prefix "g". If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc like: PATH="$HOMEBREW_PREFIX/opt/grep/libexec/gnubin:$PATH"
- Bottle: available on arm64_linux, arm64_sequoia, arm64_sonoma, arm64_tahoe, arm64_ventura, sonoma, ventura, x86_64_linux

## Freshness

- Page generated: 2026-07-08
- Package-manager version: 3.12
- Local data: ok
- Upstream repository: https://www.gnu.org/software/grep/
- info: No package-manager update timestamp was available.
- info: Release/tag comparison is only available for GitHub repositories.
## Project history and usage

GNU grep is the GNU Project's implementation of grep, the Unix text-search utility whose name comes from the ed command pattern g/re/p. As a package, it is one of the canonical command-line tools: tiny at the interface, deep in implementation, and present in nearly every Unix-like software collection.

The original grep came from early Unix culture at Bell Labs; GNU grep belongs to the later free-software lineage that reimplemented core Unix utilities for the GNU operating system and for portable Unix-like environments. Package managers care about both stories: grep is a standard shell verb, while GNU grep brings GNU options, performance engineering, and portability.

### Project history

The Unix oral-history account attributes the original grep idea to Doug McIlroy asking Ken Thompson to lift the regular-expression recognizer out of the editor into a one-pass program. That origin explains the enduring shape of grep: read input sequentially, match a pattern, and print selected lines.

GNU grep's source distribution credits Mike Haertel with the main program and the DFA and kwset matchers, Isamu Hasegawa and others with the POSIX regular-expression matcher, James Woods with early Boyer-Moore-style filtering ideas, and later maintainers including Alain Magloire, Bernhard Rosenkranzer, Stepan Kasal, Tony Abou-Assaleh, Jim Meyering, and Paolo Bonzini.

GNU grep's implementation history is unusually important for such a familiar command. The README describes a lazy-state deterministic matcher combined with Boyer-Moore and Aho-Corasick fixed-string searches, allowing the program to reject impossible input before invoking the full regular-expression matcher. That performance lineage is why GNU grep is discussed not only as a utility but also as an example of practical string-search engineering.

### Adoption history

grep became part of the ordinary Unix vocabulary because it solves a primitive shell need: find matching text in streams and files. GNU grep extended that role across GNU/Linux systems and other Unix-like package sets, while Homebrew and other macOS package managers package it for users who want GNU behavior alongside or instead of platform grep.

The GNU project page documents stable source releases on GNU download servers, Git development through Savannah, bug and commit mailing lists, translation infrastructure, and the manual. That is the classic GNU adoption model: tarball releases, public development, man/info documentation, and downstream distribution through operating-system packages.

### How it is used

At the interface, GNU grep searches one or more input files for lines matching one or more patterns and prints matching lines by default. Its ordinary forms cover basic regular expressions, extended regular expressions through grep -E, fixed strings through grep -F, pattern files through -f, recursive search, context lines, filename and line-number prefixes, binary-file behavior, and optional color highlighting.

GNU grep also carries decades of compatibility decisions. The manual marks POSIX-specified options, labels GNU long options as extensions, and documents behavior across encodings, binary data, directories, and performance-sensitive pattern sets. That combination makes it both a user command and a portability boundary for shell scripts.

### Why package nerds care

GNU grep is package-nerd significant because it sits in the base-toolchain layer. Scripts, build systems, test harnesses, log pipelines, and interactive shell sessions assume some grep-like command exists, but exact behavior can differ between GNU, BSD, BusyBox, and other implementations.

The egrep and fgrep names show the packaging tension clearly. GNU grep 2.5.3 deprecated those separate commands in 2007, and GNU grep 3.8 began warning that they are obsolescent in favor of grep -E and grep -F. Package maintainers still have to decide how to ship compatibility links while nudging users toward the POSIX-style option forms.

For macOS package users, GNU grep is also a namespace package: Homebrew installs GNU utilities in ways that avoid silently replacing system tools unless users opt into GNU-prefixed commands or path changes.

### Timeline

- 1973: The original grep entered early Unix culture as a standalone regular-expression search command.
- 1992: GNU grep source files carry Free Software Foundation copyright years beginning in 1992.
- 2007: GNU grep 2.5.3 deprecated the egrep and fgrep command names in favor of grep -E and grep -F.
- 2012: GNU grep 2.12 adjusted recursive symlink behavior and added the --dereference-recursive alias for -R.
- 2014: GNU grep 2.21 made GREP_OPTIONS obsolescent with diagnostics.
- 2020: GNU grep 3.6 removed GREP_OPTIONS behavior.
- 2022: GNU grep 3.8 switched -P from PCRE to PCRE2 and began warning for obsolescent egrep and fgrep invocations.
- 2025: GNU grep 3.12 removed the long-obsolete --unix-byte-offsets option and included portability fixes for large directories and some Unicode cases.

### Related projects

- ed is the editor whose g/re/p command gave grep its name.
- egrep and fgrep survive as historically separate entry points but map conceptually to grep -E and grep -F.
- GNU sed, GNU awk, find, xargs, ripgrep, The Silver Searcher, ack, git grep, and BusyBox grep all live near GNU grep in the practical text-search ecosystem.
- PCRE and PCRE2 matter because GNU grep's -P mode uses Perl-compatible regular-expression support when built with it.

### Sources

- <https://dspinellis.github.io/oral-history-of-unix/frs122/unixhist/finalhis.htm>
- <https://ftp.gnu.org/gnu/grep/grep-3.12.tar.xz>
- <https://savannah.gnu.org/git/?group=grep>
- <https://www.gnu.org/software/grep/>
- <https://www.gnu.org/software/grep/manual/grep.html>


## Security Notes

narrow executable package without higher-risk signals.

- **Geiger risk:** green / low
- narrow executable package without higher-risk signals

## Source Database Details

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

## Other Package-Manager Records

- Debian apt - grep - 3.11-4: normalized package name match | Debian stable package indexes: grep from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | GNU grep, egrep and fgrep | https://www.gnu.org/software/grep/
- Ubuntu apt - grep - 3.11-4build1: normalized package name match | Ubuntu 24.04 LTS package indexes: grep from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | GNU grep, egrep and fgrep | https://www.gnu.org/software/grep/
- apk - grep - 3.12-r0: normalized package name match | Alpine Linux edge package indexes: grep from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | Searches input files for lines containing a match to a specified pattern | https://www.gnu.org/software/grep/grep.html
- apk - grep-doc - 3.12-r0: normalized package name match | Alpine Linux edge package indexes: grep-doc from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | Searches input files for lines containing a match to a specified pattern (documentation) | https://www.gnu.org/software/grep/grep.html
- dnf - grep - 3.12-3.fc44: normalized package name match | Fedora Rawhide package metadata: grep from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/e5ca8ce900cd68f5419e1c39ae517343100b306336cbaeb70a3c153121d95094-primary.xml.zst | Pattern matching utilities | https://www.gnu.org/software/grep/
- pacman - grep - 3.12-2: normalized package name match | Arch Linux sync databases: grep from https://geo.mirror.pkgbuild.com/core/os/x86_64/core.db.tar.gz | A string search utility | https://www.gnu.org/software/grep/
- zypper - grep - 3.12-1.3: normalized package name match | openSUSE Tumbleweed package metadata: grep from https://download.opensuse.org/tumbleweed/repo/oss/repodata/be8d3611d25469107f32075a1697e69ec57a2b850b42348a658cc671ad5ec2b50760d02c3e59524d50da9a11d5be799bdaffba2e166e8ca8858512e3c0bd665d-primary.xml.zst | Print lines matching a pattern | https://www.gnu.org/software/grep/
- zypper - grep-lang - 3.12-1.3: normalized package name match | openSUSE Tumbleweed package metadata: grep-lang from https://download.opensuse.org/tumbleweed/repo/oss/repodata/be8d3611d25469107f32075a1697e69ec57a2b850b42348a658cc671ad5ec2b50760d02c3e59524d50da9a11d5be799bdaffba2e166e8ca8858512e3c0bd665d-primary.xml.zst | Translations for package grep | https://www.gnu.org/software/grep/
- MacPorts - grep: normalized package name match | MacPorts ports tree: sysutils/grep/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1
- Chocolatey - grep: normalized package name match | Chocolatey community package catalog: grep from http://community.chocolatey.org/api/v2/Packages?$filter=IsLatestVersion&$select=Id&$top=1000&$skiptoken='11','gpg4win-vanilla'
- Scoop - main/grep: normalized package name match | Scoop official bucket manifest trees: bucket/grep.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1


## Related links

- [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.
- [Developer build packages](https://www.automicvault.com/pkg/developer-build-tools/) - Matched build, compiler, generator, or developer workflow metadata.
- [Networking and protocol packages](https://www.automicvault.com/pkg/networking-protocol-tools/) - Matched network, protocol, or remote-service metadata.
- [pcre2](https://www.automicvault.com/pkg/brew/pcre2/) - Runtime dependency declared by Homebrew.
- [pkgconf](https://www.automicvault.com/pkg/brew/pkgconf/) - Build dependency declared by Homebrew.
- [crosstool-ng](https://www.automicvault.com/pkg/brew/crosstool-ng/) - Popular package that depends on this formula.
- [tfenv](https://www.automicvault.com/pkg/brew/tfenv/) - Popular package that depends on this formula.
- [tofuenv](https://www.automicvault.com/pkg/brew/tofuenv/) - Popular package that depends on this formula.
- [enscript](https://www.automicvault.com/pkg/brew/enscript/) - Shares av.db curated category or tags: cli, developer-tools, gnu, text-processing.
- [gawk](https://www.automicvault.com/pkg/brew/gawk/) - Shares av.db curated category or tags: cli, developer-tools, gnu, text-processing.
- [grok](https://www.automicvault.com/pkg/brew/grok/) - Shares av.db curated category or tags: cli, developer-tools, regular-expressions, text-processing.
- [gsar](https://www.automicvault.com/pkg/brew/gsar/) - Shares av.db curated category or tags: cli, developer-tools, search, text-processing.
- [rgxg](https://www.automicvault.com/pkg/brew/rgxg/) - Shares av.db curated category or tags: cli, developer-tools, regular-expressions, text-processing.
- [ssed](https://www.automicvault.com/pkg/brew/ssed/) - Shares av.db curated category or tags: cli, developer-tools, regular-expressions, text-processing.
- [ugrep](https://www.automicvault.com/pkg/brew/ugrep/) - Shares av.db curated category or tags: cli, developer-tools, search, text-processing.
- [wdiff](https://www.automicvault.com/pkg/brew/wdiff/) - Shares av.db curated category or tags: cli, developer-tools, gnu, text-processing.
- [gnu-sed](https://www.automicvault.com/pkg/brew/gnu-sed/) - Local package facts share a topical domain. Shared terms: cli, developer, developer-tools, gnu, processing.

## Combined YAML source

View the package source record on GitHub. [combined/grep.yml](https://github.com/automic-vault/db/blob/main/combined/grep.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
