Shell Scripting Recipes by Chris F. A. Johnson & Jayant Varma

Shell Scripting Recipes by Chris F. A. Johnson & Jayant Varma

Author:Chris F. A. Johnson & Jayant Varma
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


8.5 dateshift—Add or Subtract a Number of Days

The date2julian script lets me convert a date to an integer. Now you need to put that to use and get yesterday’s date, or the date one week ago.

How It Works

By encapsulating the conversion to Julian Day, the arithmetic, and the conversion back to ISO date in the dateshift function, a single command can return the date at any offset from any given date.

Usage

dateshift [YYYY-MM-DD] OFFSET

If a date (in ISO format) is not entered on the command line, today’s date is used. Therefore, to retrieve yesterday’s date:

$ dateshift -1 ## at the time of writing the first Edition, it is October 15, 2004

2004-10-14

When is Twelfth Night?

$ dateshift 2004-12-25 +12

2005-01-06



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.