Skip to main content
fixed cus FAQ anchor
Source Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k

Unfortunately, none of the POSIX command line utilities provide arithmetic on dates. date -d and date +%s are the way to go if you have them, but they're GNU extensions.

There's a clumsy hack with touch that sort of works for checking that a date is at least n days in the past:

touch -t 201009090000 stamp
if [ -n "$(find stamp -mtime +42)" ]; then ...

(Note that this code may be off by one if DST started or stopped in the interval and the script runs before 1am.)

Several people have ended up implementing date manipulation libraries in Bourne or POSIX shell. There are a few examples and links in the comp.unix.shell FAQcomp.unix.shell FAQ.

Installing GNU tools may be the way of least pain.

Unfortunately, none of the POSIX command line utilities provide arithmetic on dates. date -d and date +%s are the way to go if you have them, but they're GNU extensions.

There's a clumsy hack with touch that sort of works for checking that a date is at least n days in the past:

touch -t 201009090000 stamp
if [ -n "$(find stamp -mtime +42)" ]; then ...

(Note that this code may be off by one if DST started or stopped in the interval and the script runs before 1am.)

Several people have ended up implementing date manipulation libraries in Bourne or POSIX shell. There are a few examples and links in the comp.unix.shell FAQ.

Installing GNU tools may be the way of least pain.

Unfortunately, none of the POSIX command line utilities provide arithmetic on dates. date -d and date +%s are the way to go if you have them, but they're GNU extensions.

There's a clumsy hack with touch that sort of works for checking that a date is at least n days in the past:

touch -t 201009090000 stamp
if [ -n "$(find stamp -mtime +42)" ]; then ...

(Note that this code may be off by one if DST started or stopped in the interval and the script runs before 1am.)

Several people have ended up implementing date manipulation libraries in Bourne or POSIX shell. There are a few examples and links in the comp.unix.shell FAQ.

Installing GNU tools may be the way of least pain.

fixed formatting
Source Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k

Unfortunately, none of the POSIX command line utilities provide arithmetic on dates. date -d and date +%s are the way to go if you have them, but they're GNU extensions.

There's a clumsy hack with touch that sort of works for checking that a date is at least n days in the past:

touch -t 201009090000 stamp
if [ -n "$(find stamp -mtime +42)" ]; then ...

(Note that this code may be off by one if DST started or stopped in the interval and the script runs before 1am.)

Several people have ended up implementing date manipulation libraries in Bourne or POSIX shell. There are a few examples and links in the [comp.unix.shell FAQ](http://cfajohnson.com/shell/cus-faq.html#6]comp.unix.shell FAQ.

Installing GNU tools may be the way of least pain.

Unfortunately, none of the POSIX command line utilities provide arithmetic on dates. date -d and date +%s are the way to go if you have them, but they're GNU extensions.

There's a clumsy hack with touch that sort of works for checking that a date is at least n days in the past:

touch -t 201009090000 stamp
if [ -n "$(find stamp -mtime +42)" ]; then ...

(Note that this code may be off by one if DST started or stopped in the interval and the script runs before 1am.)

Several people have ended up implementing date manipulation libraries in Bourne or POSIX shell. There are a few examples and links in the [comp.unix.shell FAQ](http://cfajohnson.com/shell/cus-faq.html#6].

Installing GNU tools may be the way of least pain.

Unfortunately, none of the POSIX command line utilities provide arithmetic on dates. date -d and date +%s are the way to go if you have them, but they're GNU extensions.

There's a clumsy hack with touch that sort of works for checking that a date is at least n days in the past:

touch -t 201009090000 stamp
if [ -n "$(find stamp -mtime +42)" ]; then ...

(Note that this code may be off by one if DST started or stopped in the interval and the script runs before 1am.)

Several people have ended up implementing date manipulation libraries in Bourne or POSIX shell. There are a few examples and links in the comp.unix.shell FAQ.

Installing GNU tools may be the way of least pain.

Source Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k

Unfortunately, none of the POSIX command line utilities provide arithmetic on dates. date -d and date +%s are the way to go if you have them, but they're GNU extensions.

There's a clumsy hack with touch that sort of works for checking that a date is at least n days in the past:

touch -t 201009090000 stamp
if [ -n "$(find stamp -mtime +42)" ]; then ...

(Note that this code may be off by one if DST started or stopped in the interval and the script runs before 1am.)

Several people have ended up implementing date manipulation libraries in Bourne or POSIX shell. There are a few examples and links in the [comp.unix.shell FAQ](http://cfajohnson.com/shell/cus-faq.html#6].

Installing GNU tools may be the way of least pain.