UNIX / Linux: Increment The Date

ht‮ww//:spt‬w.lautturi.com
UNIX / Linux: Increment The Date

There are several ways to increment the date in Unix or Linux. Here are a few options:

  1. Using the date command:
date -d "today + 1 day"

This command will output the date for the next day. You can replace "1 day" with any other time interval, such as "2 weeks" or "3 months".

  1. Using the cal command:
cal `date +%m %Y` | sed -n '/^   /{n;p}'

This command will output the calendar for the current month, with the current day highlighted. You can use the -A option to specify a number of months to add to the current date:

cal -A 3 `date +%m %Y` | sed -n '/^   /{n;p}'

This will output the calendar for three months after the current month.

  1. Using the awk command:
date +%Y%m%d -d "$(awk 'BEGIN{print strftime("%Y-%m-%d", systime()+86400*7)}')"

This command will output the date one week from the current date. You can replace "86400*7" with any other number of seconds to add to the current date.

Created Time:2017-10-30 14:27:23  Author:lautturi