User Tools

Site Tools


programming:bash:notes

Programming - Bash - Notes

Echo the current month in YYYY-MM format:

date +%Y-%m

Echo the previous month in YYYY-MM format:

echo $(if [ $(expr $(date +%m) - 1) -eq 0 ]; then echo $(expr $(date +%Y) - 1)-12; else if [ $(expr $(date +%m) - 1) -gt 9 ]; then echo $(date +%Y)-$(expr $(date +%m) - 1); else echo $(date +%Y)-0$(expr $(date +%m) - 1); fi; fi)
programming/bash/notes.txt · Last modified: 2020/09/23 16:06 by bas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki