cmp(1) on Solnix vs Linux and the BSDs
On Solnix, cmp is the illumos cmp at /usr/bin/cmp, which documents only -l and -s and takes octal or decimal skip offsets. The extra options of Linux cmp (-b, -i, -n, long options) come with the diffutils cmp in pkgs.solnix.diffutils.
The manual pages
- Solnix: cmp(1) from
pkgs.solnix.illumos-world-man; the default on Solnix · illumos.org - Solnix: cmp(1) from
pkgs.solnix.diffutils; add the package to get it - Linux: cmp(1) diffutils-3.12
- FreeBSD: cmp(1) 15.1-RELEASE
- OpenBSD: cmp(1) 8.0
- NetBSD: cmp(1) 11.0
- Standard: POSIX.1-2024 (IEEE Std 1003.1-2024),
cmp
What Solnix runs
/usr/bin/cmp is the illumos cmp. No other illumos variants are shipped. The alternative is cmp(1) from pkgs.solnix.diffutils, which is not on PATH by default. Add that package to get it.
Differences
| Compared with | Topic | What differs |
|---|---|---|
| Linux | same program as the alternative | The Solnix diffutils package's cmp page has the same synopsis and options as the Linux diffutils cmp page. Install pkgs.solnix.diffutils to get Linux behaviour. The default /usr/bin/cmp is a different program.Source: Solnix cmp(1) from pkgs.solnix.diffutils SYNOPSIS, DESCRIPTION; Linux cmp(1) SYNOPSIS, DESCRIPTION |
| Linux | Linux options missing | Solnix /usr/bin/cmp documents only -l and -s and no long options. Linux cmp also has -b, -i, -n, -v and --help, plus long forms such as --verbose and --quiet; the Solnix page does not document them.Source: illumos cmp(1) SYNOPSIS, OPTIONS; Linux cmp(1) DESCRIPTION (option list) |
| FreeBSD | FreeBSD extensions | FreeBSD cmp has -b, -h, -i, -n, -x and -z, marked as extensions to the standard; the Solnix page documents none of them, including -x, FreeBSD's hexadecimal form of -l.Source: FreeBSD cmp(1) SYNOPSIS, -x, STANDARDS; illumos cmp(1) OPTIONS |
| NetBSD | -c option | NetBSD cmp has -c, which compares with getc(3) instead of mmap(2). The Solnix page documents no -c.Source: NetBSD cmp(1) -c; illumos cmp(1) SYNOPSIS |
| all four | skip offset syntax | Solnix skip1 and skip2 are octal or decimal, a leading 0 meaning octal. FreeBSD, OpenBSD and NetBSD also take a leading 0x for hexadecimal, and Linux takes size suffixes (kB, K, MB, M ...). The Solnix page documents neither. Source: illumos cmp(1) DESCRIPTION (skip1 and skip2); FreeBSD, OpenBSD and NetBSD cmp(1) DESCRIPTION (skip1); Linux cmp(1) SKIP values |
| Linux | exit status for errors | Solnix cmp returns 0 for identical files, 1 for different files and >1 on error. Linux documents exactly 2 for trouble. Source: illumos cmp(1) EXIT STATUS; Linux cmp(1) DESCRIPTION (last paragraph) |
| FreeBSD, OpenBSD, NetBSD | EOF message when one file is a prefix | When one file is a prefix of the other and -s is not given, FreeBSD and OpenBSD write an EOF message to standard error and NetBSD to standard output. The Solnix page says only that the fact is noted.Source: FreeBSD cmp(1) EXIT STATUS; OpenBSD cmp(1) EXIT STATUS; NetBSD cmp(1) EXIT STATUS; illumos cmp(1) DESCRIPTION |
| Linux | missing FILE2 reads standard input | On Linux, a missing FILE2 means standard input. On Solnix, file1 and file2 are both required operands, and standard input is selected with a minus-sign operand. Using standard input for both is an error. Source: Linux cmp(1) SYNOPSIS, DESCRIPTION (last paragraph); illumos cmp(1) SYNOPSIS, OPERANDS |
Everyday tasks
| Task | Solnix | Linux | FreeBSD | OpenBSD | NetBSD |
|---|---|---|---|---|---|
| compare two files byte by byte | cmp file1 file2 | cmp file1 file2 | cmp file1 file2 | cmp file1 file2 | cmp file1 file2 |
| compare files quietly, exit status only | cmp -s file1 file2 | cmp -s file1 file2 | cmp -s file1 file2 | cmp -s file1 file2 | cmp -s file1 file2 |
| list every differing byte with its values | cmp -l file1 file2 | cmp -l file1 file2 | cmp -l file1 file2 | cmp -l file1 file2 | cmp -l file1 file2 |
Standards
- POSIX: cmp is a POSIX.1-2024 utility.
- Solnix: ATTRIBUTES: Interface Stability is Standard; CSI is Enabled.
- FreeBSD: cmp is expected to be IEEE Std 1003.2 (“POSIX.2”) compatible.
-b,-h,-i,-n,-x,-zand the skip1 and skip2 arguments are extensions. - OpenBSD: cmp is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification. skip1 and skip2 are extensions.
- NetBSD: cmp is expected to be IEEE Std 1003.2 (“POSIX.2”) compatible.
Writing portable scripts
- Use only
-land-swith file1 and file2 in portable scripts. Those are the only options all five systems document. - Test the exit status as 0 (same), 1 (different) or greater than 1 (error); do not test for exactly 2, or rely on the text of the EOF message.
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.