Sign in

grep(1) on Solnix vs Linux and the BSDs

On Solnix, grep is the illumos grep at /usr/bin/grep, with short options plus one long option, --label, and -b printing a block number where Linux and the BSDs print a byte offset. It lacks -m, which all four counterparts list, and -P, which Linux documents.

What Solnix runs

A default Solnix system runs the illumos grep at /usr/bin/grep. /usr/xpg4/bin/grep is also shipped; the page's HISTORY says the former /usr/xpg4/bin versions are now installed in /usr/bin. egrep and fgrep are the same as grep -E and grep -F. GNU grep is available from pkgs.solnix.gnugrep, not on PATH by default; pkgs.solnix.grep also publishes a grep(1) page.

Differences

Compared withTopicWhat differs
LinuxGNU grep via pkgs.solnix.gnugrepThe pkgs.solnix.gnugrep page is GNU grep, the program the Linux page (gnugrep-3.12) documents, with long options, -P, -m, --color and -z. The default illumos grep has none of these except one long option, --label.
Source: Solnix grep(1) from pkgs.solnix.gnugrep OPTIONS; Linux grep(1) OPTIONS; illumos grep(1) SYNOPSIS
all four-b meaningSolnix grep -b prints the block number of the line, with the first block being 0. Linux, FreeBSD, OpenBSD and NetBSD print the byte offset. Do not use -b to locate data by byte position on Solnix.
Source: illumos grep(1) -b; Linux grep(1) -b, --byte-offset; FreeBSD grep(1) -b; OpenBSD grep(1) -b; NetBSD grep(1) -b
FreeBSD, OpenBSD, NetBSD-a and -I (binary files)Solnix /usr/bin/grep has no -a (binary as text) or -I (skip binary files), and its NOTES say results are unspecified for binary data. FreeBSD, OpenBSD and NetBSD document -a and -I.
Source: illumos grep(1) SYNOPSIS, NOTES; FreeBSD grep(1) -a, -I; OpenBSD grep(1) -a, -I; NetBSD grep(1) -a, -I
Linux, FreeBSD, OpenBSDlong optionsThe only long option on Solnix grep is --label=name. Linux and FreeBSD document long forms such as --regexp, --count and --ignore-case, and OpenBSD's synopsis has only a few.
Source: illumos grep(1) SYNOPSIS; Linux grep(1) OPTIONS; FreeBSD grep(1) --regexp, --count, --ignore-case; OpenBSD grep(1) SYNOPSIS
Linux, FreeBSD, NetBSDcolour outputSolnix grep has no --color, and its environment list holds only locale variables. Linux reads GREP_COLORS, and FreeBSD and NetBSD read GREP_COLOR.
Source: illumos grep(1) ENVIRONMENT VARIABLES; Linux grep(1) --color; FreeBSD grep(1) --color; NetBSD grep(1) --colour
LinuxPerl regular expressionsSolnix grep has no -P. Patterns are BREs by default, with -E for EREs and -F for fixed strings. Linux grep -P selects Perl-compatible regular expressions.
Source: illumos grep(1) SYNOPSIS, DESCRIPTION; Linux grep(1) -P, --perl-regexp
Linux, OpenBSDdefault directory for recursive searchThe Solnix page says grep reads standard input when no file operand is given, and does not make an exception for -r or -R. Linux recursive searches with no file examine the working directory, and OpenBSD -R searches the current working directory.
Source: illumos grep(1) DESCRIPTION, OPERANDS; Linux grep(1) DESCRIPTION; OpenBSD grep(1) -R
FreeBSD, NetBSDfile selection and -d/-DSolnix grep has no -d or -D to choose actions for directories and devices, and no --include or --exclude. FreeBSD and NetBSD document -d and -D, and FreeBSD documents --include, --exclude and --exclude-dir.
Source: illumos grep(1) SYNOPSIS; FreeBSD grep(1) -D, -d, --include, --exclude; NetBSD grep(1) -D, -d
OpenBSD-C argumentSolnix -C takes a required num, and -num is also accepted. OpenBSD -C[num] defaults to 2, and no space is allowed between the option and its argument.
Source: illumos grep(1) -C num, -num; OpenBSD grep(1) -C[num]
Linux, OpenBSD-s and -qSolnix STANDARDS says its -s is the same as -q for historic reasons, though OPTIONS describes -s as suppressing error messages. On Linux and OpenBSD, -s only suppresses messages about unreadable or missing files.
Source: illumos grep(1) -s, STANDARDS; Linux grep(1) -s; OpenBSD grep(1) -s

Everyday tasks

TaskSolnixLinuxFreeBSDOpenBSDNetBSD
search a file ignoring casegrep -i pattern filegrep -i pattern filegrep -i pattern filegrep -i pattern filegrep -i pattern file
show line numbers with matching linesgrep -n pattern filegrep -n pattern filegrep -n pattern filegrep -n pattern file—
count matching linesgrep -c pattern filegrep -c pattern filegrep -c pattern filegrep -c pattern filegrep -c pattern file
list files that contain a matchgrep -l pattern filegrep -l pattern filegrep -l pattern filegrep -l pattern file—
list files that contain no matchgrep -L pattern filegrep -L pattern file—grep -L pattern filegrep -L pattern file
search a directory tree recursivelygrep -r pattern dir—grep -R pattern dir——
match an extended regular expressiongrep -E pattern filegrep -E pattern filegrep -E pattern filegrep -E pattern filegrep -E pattern file
match a fixed string, not a regexgrep -F pattern filegrep -F pattern filegrep -F pattern filegrep -F pattern filegrep -F pattern file
show lines of context after each matchgrep -A num pattern filegrep -A num pattern filegrep -A num pattern filegrep -A num pattern filegrep -A num pattern file

Standards

  • POSIX: grep is a POSIX.1-2024 utility.
  • Solnix: STANDARDS: compliant with IEEE Std 1003.1-2008 (“POSIX.1”) except that -s is the same as -q in the current implementation; the flags [-AbBChHrRw] are extensions. INTERFACE STABILITY: Committed.
  • 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, -i, -v, -c, -l, -n, -q, -e and -f. Use grep -E and grep -F, not egrep and fgrep, as the Solnix page advises.
  • Use -q for existence tests. Avoid -m, -P, -a, -I and --color, which /usr/bin/grep does not document, -o with -v, which it does not support, and -b, which means a block number on Solnix and a byte offset elsewhere.

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.