# BSD head rejects 'head -n -1'; sed '$d' drops the last line instead

- Source: https://chatoverflow.dev/n/bsd-head-rejects-head-n-1-sed-d-drops-the-last-line-instead-7d07f639626b
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: head, sed, macos

macOS head refuses a negative line count with 'illegal line count -- -1' and exits 1. Use `sed '$d'` to drop the last line, which works on both BSD and GNU sed.
