cmp(1) on Solnix vs Linux and the BSDs
A default Solnix system runs the illumos cmp at /usr/bin/cmp, which has only -l and -s. The published Solnix page describes GNU diffutils cmp (pkgs.solnix.diffutils), so options such as -b, -i, -n and the long options are not on PATH unless you install that package.
The manual pages
What Solnix runs
The published cmp(1) page is GNU diffutils 3.10 (pkgs.solnix.diffutils), but the command on PATH is the illumos /usr/bin/cmp, whose synopsis is `cmp [-l | -s] file1 file2 [skip1] [skip2]`. No other variants are shipped. GNU cmp is the same program as on Linux (diffutils 3.12 page). Install pkgs.solnix.diffutils to get it. The bundle does not say where the package installs it or whether it comes first on PATH.
Differences
| Compared with | Topic | What differs |
|---|---|---|
| Linux | which cmp you get | The Solnix page documents GNU cmp, the same program as Linux diffutils. The default /usr/bin/cmp is the illumos one, which accepts only -l and -s. Scripts written for Linux cmp options fail on a default Solnix system.Source: Solnix cmp(1) header and SOLNIX DEFAULT ON PATH SYNOPSIS; Linux cmp(1) OPTIONS |
| Linux | missing GNU options in illumos cmp | illumos cmp has no -b, -i, -n, -v, --help or any long option (--bytes, --ignore-initial, --print-bytes, --verbose, --quiet, --silent). Use the skip1/skip2 operands to skip bytes. The page documents no way to limit the number of bytes compared.Source: illumos cmp(1) SYNOPSIS, OPTIONS; Linux cmp(1) -b, -i, -n, -l, -s |
| Linux | skip operand syntax | illumos skip1/skip2 are octal or decimal, and a leading 0 means octal. GNU cmp also accepts suffixes (kB, K, MB, M, and so on) and the -i SKIP1:SKIP2 form. The illumos page documents neither.Source: illumos cmp(1) DESCRIPTION; Linux cmp(1) -i, SKIP suffixes |
| FreeBSD, OpenBSD, NetBSD | hexadecimal skip offsets | The BSD pages say skip offsets are decimal, or hexadecimal with a leading 0x, or octal with a leading 0. The illumos page mentions only octal and decimal, so do not rely on 0x on a default Solnix system. Source: FreeBSD cmp(1) DESCRIPTION; OpenBSD cmp(1) DESCRIPTION; NetBSD cmp(1) DESCRIPTION; illumos cmp(1) DESCRIPTION |
| Linux | file operands and standard input | GNU cmp reads standard input if a FILE is '-' or missing, so FILE2 is optional. illumos requires both file1 and file2, uses standard input for '-', and reports an error if both refer to standard input. Source: Linux cmp(1) SYNOPSIS, DESCRIPTION; illumos cmp(1) SYNOPSIS, OPERANDS |
| Linux | exit status for errors | GNU cmp exits 2 on trouble. illumos, FreeBSD, OpenBSD and NetBSD document any value above 1. Test `-gt 1` instead of `-eq 2`.Source: Linux cmp(1) DESCRIPTION (exit status); illumos cmp(1) EXIT STATUS; FreeBSD, OpenBSD, NetBSD cmp(1) EXIT STATUS |
| FreeBSD, OpenBSD, NetBSD | EOF message when one file is a prefix | If one file is a prefix of the other, FreeBSD and OpenBSD write an EOF message to standard error unless -s is given. NetBSD writes it to standard output. The illumos page says only that the fact is noted, and does not name the stream.Source: FreeBSD cmp(1) EXIT STATUS; OpenBSD cmp(1) EXIT STATUS; NetBSD cmp(1) EXIT STATUS; illumos cmp(1) DESCRIPTION |
| FreeBSD | FreeBSD-only options | FreeBSD cmp has -h (do not follow symbolic links), -x (like -l, but hexadecimal and zero-indexed) and -z (compare file sizes first). Neither illumos nor GNU cmp lists them.Source: FreeBSD cmp(1) -h, -x, -z; illumos cmp(1) OPTIONS; Linux cmp(1) OPTIONS |
| NetBSD | -c option | NetBSD cmp -c compares with getc(3) instead of mmap(2), to help locate I/O errors when combined with -l. The option is not present in illumos or GNU cmp.Source: NetBSD cmp(1) -c; illumos cmp(1) OPTIONS; Linux cmp(1) OPTIONS |
| FreeBSD | -i and -v spelling | FreeBSD -i num1[:num2] and GNU -i SKIP1:SKIP2 are the same idea, but FreeBSD has no -v. GNU -v prints the version, and FreeBSD has --verbose only as a long form of -l.Source: FreeBSD cmp(1) -i, -l; Linux cmp(1) -i, -v, -l |
| Linux, FreeBSD | -l output detail | illumos, FreeBSD, OpenBSD and NetBSD say -l prints decimal byte numbers and octal byte values. The GNU page says only 'byte numbers and differing byte values', with no base. FreeBSD -x gives hexadecimal output instead.Source: illumos cmp(1) -l; FreeBSD cmp(1) -l, -x; Linux cmp(1) -l |
Standards
- POSIX: cmp is a POSIX.1-2024 utility.
- Solnix: illumos cmp ATTRIBUTES: Interface Stability is Standard; CSI is Enabled.
- Linux: The Linux (diffutils) page has no STANDARDS section.
- FreeBSD: cmp is expected to be IEEE Std 1003.2 (“POSIX.2”) compatible. The
-b,-h,-i,-n,-xand-zoptions and the skip1 and skip2 arguments are extensions to the standard. - OpenBSD: cmp is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification. The arguments skip1 and skip2 are extensions.
- NetBSD: cmp is expected to be IEEE Std 1003.2 (“POSIX.2”) compatible.
Writing portable scripts
- Use only
-l,-sand the file operands, which every system in the bundle documents. Do not use-b,-i,-nor long options on a default Solnix system. - Test the exit status as 0 (same), 1 (different) and above 1 (error). Do not test for exactly 2.
- Skip operands are an extension on FreeBSD and OpenBSD. Write them in decimal only, since the illumos page does not mention 0x.
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.