How to Fix bash: grex: command not found in Minimal Linux Distributions

Developers and system administrators needing to craft complex regular expressions from a set of user input strings frequently turn to grex, a command-line utility written in Rust that generates simplified, optimized regex patterns automatically. On newly provisioned cloud servers, minimal Debian/Ubuntu installations, or clean Docker containers, invoking the utility returns bash: grex: command not found.

Install grex via Native Package Repositories

Install grex directly using your Linux distribution package manager where available:

  • Arch Linux: sudo pacman -S grex
  • Alpine Linux: sudo apk add grex
  • Void Linux: sudo xbps-install -S grex
  • Debian / Ubuntu: Install via Homebrew: brew install grex

Download Official GitHub Standalone Binary Release

For Debian, Ubuntu, CentOS, or Rocky Linux systems without Homebrew, download the standalone pre-compiled binary directly into your system PATH:

GREX_VER=$(curl -s https://api.github.com/repos/pemistahl/grex/releases/latest | grep 'tag_name' | cut -d '"' -f 4)
curl -sL "https://github.com/pemistahl/grex/releases/download/${GREX_VER}/grex-${GREX_VER}-x86_64-unknown-linux-musl.tar.gz" | tar -xz
sudo mv grex /usr/local/bin/
sudo chmod +x /usr/local/bin/grex

Install via Rust Cargo

If you have the Rust development environment installed:

cargo install grex

Verify installation by executing grex --version or testing automatic regex generation with grex a b c.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.