Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can get the next month in shell?

I would like to get the current and next months using shell script, I have tried this command:

$ date '+%b'

mar

$ date +"%B %Y" --date="$(date +%Y-%m-15) next month"

March 2018

But it always displays only the current month.

Could you please help me if there is something wrong with the commands.

like image 671
achref05 Avatar asked Dec 14 '25 10:12

achref05


1 Answers

$ date -d "next month" '+%B %Y'
April 2018

Check this post about specific caveats

Note: your command works just fine for me (archlinux, bash4, date GNU coreutils 8.29)

like image 195
Gilles Quenot Avatar answered Dec 15 '25 23:12

Gilles Quenot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!