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.
The manual pages
- Solnix: grep(1) from
pkgs.solnix.illumos-world-man; the default on Solnix · illumos.org - Solnix: grep(1) from
pkgs.solnix.gnugrep; add the package to get it - Solnix: grep(1) from
pkgs.solnix.grep; add the package to get it - Linux: grep(1) gnugrep-3.12
- FreeBSD: grep(1) 15.1-RELEASE
- OpenBSD: grep(1) 8.0
- NetBSD: grep(1) 11.0
- Standard: POSIX.1-2024 (IEEE Std 1003.1-2024),
grep
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 with | Topic | What differs |
|---|---|---|
| Linux | GNU grep via pkgs.solnix.gnugrep | The 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 meaning | Solnix 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, OpenBSD | long options | The 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, NetBSD | colour output | Solnix 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 |
| Linux | Perl regular expressions | Solnix 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, OpenBSD | default directory for recursive search | The 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, NetBSD | file selection and -d/-D | Solnix 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 argument | Solnix -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 -q | Solnix 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
| Task | Solnix | Linux | FreeBSD | OpenBSD | NetBSD |
|---|---|---|---|---|---|
| search a file ignoring case | grep -i pattern file | grep -i pattern file | grep -i pattern file | grep -i pattern file | grep -i pattern file |
| show line numbers with matching lines | grep -n pattern file | grep -n pattern file | grep -n pattern file | grep -n pattern file | — |
| count matching lines | grep -c pattern file | grep -c pattern file | grep -c pattern file | grep -c pattern file | grep -c pattern file |
| list files that contain a match | grep -l pattern file | grep -l pattern file | grep -l pattern file | grep -l pattern file | — |
| list files that contain no match | grep -L pattern file | grep -L pattern file | — | grep -L pattern file | grep -L pattern file |
| search a directory tree recursively | grep -r pattern dir | — | grep -R pattern dir | — | — |
| match an extended regular expression | grep -E pattern file | grep -E pattern file | grep -E pattern file | grep -E pattern file | grep -E pattern file |
| match a fixed string, not a regex | grep -F pattern file | grep -F pattern file | grep -F pattern file | grep -F pattern file | grep -F pattern file |
| show lines of context after each match | grep -A num pattern file | grep -A num pattern file | grep -A num pattern file | grep -A num pattern file | grep -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
-sis the same as-qin 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,-eand-f. Use grep-Eand grep-F, not egrep and fgrep, as the Solnix page advises. - Use
-qfor existence tests. Avoid-m,-P,-a,-Iand--color, which/usr/bin/grepdoes not document,-owith-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.