[Bash] Calendar and Dates
Calendar
cal
May 2024
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
# all months
cal 2024
# first 6 lines
cal 2024 | head -n 6
# show one month
cal aug 2024
# prevous, current, next months
cal -3
Date
$ date
Thu May 30 12:39:26 EEST 2024
# formats
$ date +'%H:%M:%S %Y-%m-%d'
12:40:45 2024-05-30
# %F for %Y-%m-%d
date +'%H:%M:%S %F'
# %T for %H:%M:%S
date +'%T %F'
Advance example
Create files by using data
and format
echo hello there >> `date +'%F'`.txt