grep(1) on Solnix vs Linux and the BSDs
The grep(1) page Solnix publishes is GNU grep, from pkgs.solnix.grep. The grep on PATH is the illumos grep at /usr/bin/grep, which has a much smaller option set. GNU-isms such as -P, -z, -m, --include and -a are not documented for it.
The manual pages
What Solnix runs
/usr/bin/grep on a default Solnix system is illumos grep, not the GNU grep this page describes. GNU grep comes from pkgs.solnix.grep. /usr/xpg4/bin/grep is also shipped; the bundle does not describe how it differs. illumos grep documents -E, -F, -A/-B/-C, -b, -c, -e, -f, -h, -H, -i, -l, -L, -n, -o, -q, -r, -R, -s, -v, -w, -x and --label. In illumos grep, -b means block number, not byte offset, and -o cannot be combined with -v.
Differences
| Compared with | Topic | What differs |
|---|---|---|
| all four | -b meaning (illumos default) | illumos /usr/bin/grep -b prints the block number of each matching line, starting at 0. GNU grep (Solnix package and Linux), FreeBSD, OpenBSD and NetBSD print a byte offset.Source: SOLNIX DEFAULT ON PATH illumos grep(1) -b; Solnix GNU grep(1) -b; Linux grep(1) -b; FreeBSD grep(1) -b; OpenBSD grep(1) -b; NetBSD grep(1) -b |
| all four | -m missing (illumos default) | illumos /usr/bin/grep has no -m (stop after NUM matches). GNU grep, FreeBSD, OpenBSD and NetBSD all have it.Source: SOLNIX DEFAULT ON PATH illumos grep(1) SYNOPSIS; Linux grep(1) -m; FreeBSD/OpenBSD/NetBSD grep(1) option lists |
| Linux, FreeBSD, NetBSD | common extensions missing (illumos default) | illumos /usr/bin/grep does not document -a/--text, -I, -z/--null-data, -Z/--null, --include, --exclude or --color. GNU grep documents all of them, and FreeBSD and NetBSD document most of them.Source: SOLNIX DEFAULT ON PATH illumos grep(1) SYNOPSIS, OPTIONS; Solnix GNU grep(1) OPTIONS; FreeBSD grep(1) -a, -I, --include; NetBSD grep(1) -a, -I, --include |
| Linux | -P (Perl regex) | GNU grep (Solnix package and Linux) has -P for Perl-compatible regular expressions. illumos /usr/bin/grep does not, and neither do the FreeBSD, OpenBSD or NetBSD option lists.Source: Solnix GNU grep(1) -P; Linux grep(1) -P; SOLNIX DEFAULT ON PATH illumos grep(1) SYNOPSIS |
| OpenBSD | -Z meaning | OpenBSD grep -Z makes grep behave as zgrep and read compressed input. In GNU grep (Solnix package and Linux), -Z means --null: write a NUL byte after file names. illumos /usr/bin/grep has no -Z.Source: OpenBSD grep(1) -Z; Solnix GNU grep(1) -Z, --null; Linux grep(1) -Z |
| all four | -o with -v (illumos default) | illumos /usr/bin/grep does not support -o together with -v. The GNU, FreeBSD, OpenBSD and NetBSD pages state no such limit.Source: SOLNIX DEFAULT ON PATH illumos grep(1) -o; Linux grep(1) -o; FreeBSD/OpenBSD/NetBSD grep(1) -o |
| FreeBSD | -r vs -R | In illumos /usr/bin/grep, -r skips symlinks found while recursing and skips devices, FIFOs and sockets; -R follows all symlinks. The FreeBSD page describes -r and -R as having the same effect.Source: SOLNIX DEFAULT ON PATH illumos grep(1) -r, -R; FreeBSD grep(1) -d |
| OpenBSD | -C default | OpenBSD grep takes -C[num] with an optional argument, defaulting to 2, and no space is allowed before the number. illumos and GNU grep take -C num (or -num) with a required number.Source: OpenBSD grep(1) -C; SOLNIX DEFAULT ON PATH illumos grep(1) -C; Solnix GNU grep(1) -C |
| FreeBSD, NetBSD | colour variable | GNU grep (Solnix package and Linux) reads colours from GREP_COLORS. FreeBSD and NetBSD read GREP_COLOR. Source: Solnix GNU grep(1) --color; FreeBSD grep(1) --colour; NetBSD grep(1) --colour |
| Linux | same program as Linux | The published Solnix page and Linux both describe GNU grep (Linux: gnugrep-3.12), so the options match once pkgs.solnix.grep is installed and first on PATH. Source: Header COUNTERPART linux; Solnix grep(1) and Linux grep(1) OPTIONS |
Standards
- POSIX: grep is a POSIX.1-2024 utility.
- OpenBSD: The grep utility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification. The flags [
-AaBbCGHhILmoRUVwZ] are extensions to that specification.
Writing portable scripts
- Stick to
-E,-F,-c,-e,-f,-i,-l,-n,-q,-s,-vand-x. These are the options that illumos, GNU and BSD grep all document with the same meaning. - Do not use
-bfor byte offsets: illumos/usr/bin/grepprints block numbers. - If a script needs GNU options (
-P,-z,--include,-m), install pkgs.solnix.grep and call that grep explicitly instead of relying on/usr/bin/grep.
Every difference here is taken from the manual pages linked above: Solnix's published page, Linux (man-pages and the GNU and util-linux manuals), FreeBSD, OpenBSD and NetBSD. Each row names its source. Where a manual is silent, this page is too. Compiled 2026-10-26. Found a mistake? Mail hackers@lists.solnix.io.