Expensive;
I have a very simple problem, but I can not find a logic for this. I have a file with fixed dates, example 2017-10-31, I would like every month change, this date would be added with the current month. At the top date is month 10 (October), in November it was changed to 11 and so on. This change could be with a for + 1, but when it reaches 12, it would return to 01, however, the year would continue 2017 and not 2018. I believe 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