The default installed commands, such as date
, may not be compatible with general Linux systems.
$ date -d '+10 minutes' +%s
date: illegal option -- d
usage: date [-jnRu] [-I[date|hours|minutes|seconds]] [-f input_fmt]
[-r filename|seconds] [-v[+|-]val[y|m|w|d|H|M|S]]
[[[[mm]dd]HH]MM[[cc]yy][.SS] | new_date] [+output_fmt]
To resolve this, install coreutils
:
brew install coreutils
Next, add the following line to either ~/.zprofile
or ~/.bash_profile
:
export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
Afterward, the command should work as expected:
$ date -d '+10 minutes' +%s
1683467946
brew install gnu-sed
export PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
brew install grep
export PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
brew install findutils
export PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"