
How to Use date on Both macOS and Linux Scripts Step by Step
The date command differs between macOS and Linux: -d versus -v, formatting flags, epoch conversion, and portable patterns for scripts that run on both.
Tag
5 posts

The date command differs between macOS and Linux: -d versus -v, formatting flags, epoch conversion, and portable patterns for scripts that run on both.

Resolve a file's real path portably: readlink -f versus realpath, what macOS lacks, a pure-shell fallback, and how to find a script's own directory.

Check scripts for portability with checkbashisms and ShellCheck, run them under dash and busybox ash, and find the Bash features that break sh scripts.

Schedule scripts on macOS with launchd: a plist with StartCalendarInterval, load it with launchctl, logs, differences from cron and common mistakes.

Make CI scripts portable between providers: keep logic in scripts, thin YAML, no provider variables inside, a local runner and the cost of lock-in.