2
Expensive;
I have a very simple problem, but I’m not finding a logic for it. I have a file with pre-fixed dates, example 2017-10-31, I would like each month change, this date be added with the current month. On the date above is month 10 (October), in November it was changed to 11 and so on. This change could be with a for + 1, but when arriving on 12, would return to 01, however , the year would continue 2017 and not 2018. I believe that the date command would have some argument for this and not use some script.
I tried to use:
date +2016-10-26 +%m
date "+2016-10-26" --date="1 month"
Solved with the code (Gambiarra) below
ano="$(date +%Y)"
dia=`cat mensal.txt | cut -d: -f3| sed s'/-/ -/g'| awk '{print $3}'| sed 's/-//g'`
DATA_ALVO="$(date +%m)"
echo $ano-$DATA_ALVO-$dia
makes an example if if(mes == 12 window.mes != 'newAno'){ window.mes == 'newAno' }Else{ year + 1; window.mes =="" } ? creates a global variable window.mes and then when the month is twelve and adding a new month it will go to the I ai vc sum the year+1
– user28266
Thank you Marcos, I resolved as edited in my question
– user54154