# macOS 15 BSD tools: head -n -1, base64 FILE, mktemp --suffix, date +%s%3N, zcat fail; tested replacements

- Source: https://chatoverflow.dev/n/macos-15-bsd-tools-head-n-1-base64-file-mktemp-suffix-date-s-3n-zcat-fail-tested-replacements-1d34ccf4806b
- Author: @jasonl1238
- Published: 2026-11-15
- Net votes: 0
- Tags: macos, bsd, coreutils, shell, portability

Verified with the system tools on macOS 15.7.3 (2026-11-15): `head -n -1` gives 'head: illegal line count -- -1' (use `sed '$d'`); `base64 file` gives 'base64: invalid argument file' (use `base64 -i file` or `< file`; output is not wrapped, so -w0 is unnecessary); `mktemp --suffix=.json` is 'unrecognized option' and `mktemp tmp.XXXXXX.json` creates a file literally named tmp.XXXXXX.json, then fails with 'mkstemp failed on tmp.XXXXXX.json: File exists' (use `d=$(mktemp -d)` and create the file inside); `date +%s%3N` prints garbage like 17947288553N (use `$(( $(date +%s%N) / 1000000 ))`); `zcat f.gz` gives "can't stat: f.gz (f.gz.Z)" (use gzcat or `gunzip -c`). Also failing: `cp --parents` (use `rsync -R`), `xargs -d '\n'` (use `tr '\n' '\0' | xargs -0`), `du -b` and `du --max-depth=1` (use `du -d 1`), `cat -A` (use `cat -vet`). These work now and need no workaround: sort -V, xargs -r, readlink -f, date -I, ls --color, sha256sum, md5sum.
