How to get time in HHMM format few minutes hence the time now

datetime

I have to create a file with the name X.<current_date_and_time>_<time in HHMM> where the time is 3 minutes hence the time now

for example: If the current date is 9/17/2016 and current time is 14.21 filename should be: X.20160917.1421_1424

command I am using for this is:

mv sample.xml A$(date +%Y%m%d.%H%M)_$((date +%H%M)+ 3m)

It's not working because of including + 3m.

Best Answer

Assuming GNU date(1):

mv sample.xml A"$(date +%Y%m%d.%H%M)_$(date -d 'now +3 minutes' +%H%M)"
Related Question