How do I add X days to date and get new date?

You can just use the -d switch and provide a date to be calculated

date
Sun Sep 23 08:19:56 BST 2012
NEW_expration_DATE=$(date -d "+10 days")
echo $NEW_expration_DATE
Wed Oct 3 08:12:33 BST 2012 
  -d, --date=STRING
          display time described by STRING, not ‘now’

This is quite a powerful tool as you can do things like

date -d "Sun Sep 11 07:59:16 IST 2012+10 days"
Fri Sep 21 03:29:16 BST 2012

or

TZ=IST date -d "Sun Sep 11 07:59:16 IST 2012+10 days"
Fri Sep 21 07:59:16 IST 2012

or

prog_end_date=`date '+%C%y%m%d' -d "$end_date+10 days"`

So if $end_date=20131001 then $prog_end_date=20131011


You can use "+x days" as format string:

$ date -d "+10 days"

$ date -v -1d

In order to get 1 day back date using date command:

$ date -v -1d

It will give (current date -1) means 1 day before .

$ date -v +1d

This will give (current date +1) means 1 day after.

Similarly below written code can be used in place of "d" to find out year,month etc.

y-Year
m-Month 
w-Week 
d-Day 
H-Hour 
M-Minute  
S-Second