Sign in

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.

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 withTopicWhat differs
Linuxsame program as the alternativeThe 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
LinuxLinux options missingSolnix /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)
FreeBSDFreeBSD extensionsFreeBSD 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 optionNetBSD 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 fourskip offset syntaxSolnix 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
Linuxexit status for errorsSolnix 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, NetBSDEOF message when one file is a prefixWhen 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
Linuxmissing FILE2 reads standard inputOn 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

TaskSolnixLinuxFreeBSDOpenBSDNetBSD
compare two files byte by bytecmp file1 file2cmp file1 file2cmp file1 file2cmp file1 file2cmp file1 file2
compare files quietly, exit status onlycmp -s file1 file2cmp -s file1 file2cmp -s file1 file2cmp -s file1 file2cmp -s file1 file2
list every differing byte with its valuescmp -l file1 file2cmp -l file1 file2cmp -l file1 file2cmp -l file1 file2cmp -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, -z and 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 -l and -s with 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.