truncate(1) on Solnix vs Linux and the BSDs
truncate is not in the Solnix base system; install pkgs.solnix.coreutils to get the GNU coreutils truncate, which is the same program as on Linux. FreeBSD's truncate differs: it has no long options, no -o IO-block meaning, and adds -d/-l hole-punching.
The manual pages
- Solnix: truncate(1) from
pkgs.solnix.coreutils - Linux: truncate(1) coreutils-full-9.11
- FreeBSD: truncate(1) 15.1-RELEASE
What Solnix runs
Not installed by default: add pkgs.solnix.coreutils. The bundle shows no other illumos variants and does not say whether the base system ships any other truncate. The published page is GNU coreutils 9.7.
Differences
| Compared with | Topic | What differs |
|---|---|---|
| Linux | same program | The Solnix page (pkgs.solnix.coreutils) and the Linux page are the same GNU coreutils truncate. Both have the same synopsis, options and SIZE syntax. The Solnix page is from coreutils 9.7; the Linux page text is from a later build. Source: Solnix truncate(1) SYNOPSIS, OPTIONS; Linux truncate(1) SYNOPSIS, OPTIONS |
| FreeBSD | -o meaning | On Solnix and Linux, -o treats SIZE as a number of IO blocks instead of bytes. On FreeBSD, -o takes an offset in bytes and only works together with -d. A script using -o behaves differently on FreeBSD.Source: Solnix truncate(1) -o, --io-blocks; FreeBSD truncate(1) -o offset |
| FreeBSD | hole punching (-d, -l) | FreeBSD has -d with -l length and optional -o offset to zero a region, deallocating space if the file system supports hole-punching. The Solnix page documents no -d or -l.Source: FreeBSD truncate(1) SYNOPSIS, -d, -l; Solnix truncate(1) OPTIONS |
| FreeBSD | long options | Solnix has --size, --reference, --no-create, --io-blocks, --help and --version. The FreeBSD page documents only the short options -c, -r, -s, -d, -o and -l.Source: Solnix truncate(1) OPTIONS; FreeBSD truncate(1) SYNOPSIS |
| FreeBSD | -s is required on FreeBSD syntax | FreeBSD requires exactly one of -r, -s and -d. The Solnix synopsis is only 'truncate OPTION... FILE...' and the page does not say that exactly one of them is required.Source: FreeBSD truncate(1) DESCRIPTION (Exactly one of the -r, -s and -d options); Solnix truncate(1) SYNOPSIS |
| FreeBSD | size modifiers | Solnix accepts the prefixes + - < > / %. FreeBSD documents only + - % /. The < (at most) and > (at least) prefixes are not in the FreeBSD page. Source: Solnix truncate(1) SIZE modifying characters; FreeBSD truncate(1) -s |
| FreeBSD | size suffixes | Solnix accepts K,M,G,T,P,E,Z,Y,R,Q (powers of 1024), KB,MB,... (powers of 1000) and KiB-style names. FreeBSD documents only K, M, G, T, in upper or lower case. Source: Solnix truncate(1) SIZE argument; FreeBSD truncate(1) DESCRIPTION (suffixed with one of K, M, G or T) |
| FreeBSD | -c and error reporting | FreeBSD states that -c does not treat a missing file as an error: no message and no effect on exit value. FreeBSD also continues with the remaining files after a failure. The Solnix page does not describe either behaviour or its exit status.Source: FreeBSD truncate(1) -c, EXIT STATUS; Solnix truncate(1) -c, --no-create |
| FreeBSD | -s minus behaviour | FreeBSD says a - prefix reduces length by no more than the given bytes, to a minimum of zero. The Solnix page just says '-' reduces by, with no stated minimum. Source: FreeBSD truncate(1) -s; Solnix truncate(1) SIZE modifying characters |
Standards
- POSIX: truncate is not a POSIX.1-2024 utility.
- FreeBSD: The truncate utility conforms to no known standards.
Writing portable scripts
- For a portable script use only
-c,-rand-swith a plain byte count or the K/M/G/T suffixes; avoid-o, long options and the < and > prefixes, which FreeBSD does not document. - Do not assume truncate exists on a default Solnix system: check for it or install pkgs.solnix.coreutils.
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.