0

This question already has an answer here:

By assigning the date to awk, I can get current date as following in yyyy-mm-dd:

awk -F, -v date="20$(date +%y-%m-%d)" '{print date}'

Output:

2019-02-17

Is there a way to add number of days to current date, let's say 7, so the output would be:

2019-02-24

Noting that using a method like below isn't providing the required output:

awk -F, -v date="20$(date +%y-%m-%d +7 days)" '{print date}'

Solution here is not providing same date format

marked as duplicate by Rui F Ribeiro, Kusalananda awk Feb 17 at 7:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

You can use format

date +%y-%m-%d --date="7 days"

to gate date after 7 days

And instead of adding 20 in front just use date on this way:

date=$(date +%Y-%m-%d --date="7 days")
  • How date formatted in yyyy-mm-dd? – Eng7 Feb 17 at 7:17
  • 1
    Replace small "y" with caps "Y" and you will have 4 numbers year – Romeo Ninov Feb 17 at 7:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.