/bin/date and coreutils
David Liontooth
liontooth at cogweb.net
Mon May 7 11:52:58 PDT 2007
In OSX, /bin/date doesn't support the -d switch
date: illegal option -- d
In the case of sed, I needed the -r switch and found gsed, providing
gnused, in macports, which works great.
The date utility is bundled in coreutils on debian, along with cat chown
df ln and so on -- I imagine this can't easily be ported?
Details:
I run a certain job daily, which puts the results in a directory named
by that day's date.
In a script operating on these results, I need to indicate which
directory to work on by how many days ago it was created.
So I might set up this command in cron:
work 4
to run the script "work" in the directory created four days ago. To pick
the date, I use
DAY="$(date -d "-$1 day" +%F)"
The -d switch allows me to subtract days (or minutes or seconds) from
today's date.
Is there a way to subtract n days from a date using the OSX date utility?
Dave
More information about the macports-users
mailing list