Recently found that the date command is especially useful (not in Mac)
1. Get today's date
[Email protected] ~]# date +%y%m%d20141123
2. Get the date of a day
" 2014-11-12 " +%y%m%D20141112
This seems like crap, but it's okay, keep looking.
3. Get a day of the week
" 2014-11-23 " +%w0
4, get a day two months before the week
" -2 month 2014-11-23 " +%w2
5. Similarly:
" -1 week "+%y%m%--date="-24 hour"
6. Format:
%a weekday abbreviation for the current field (Sun.. Sat)%a The current week of the field is fully written (Sunday. Saturday)%b The month abbreviation for the current field (Jan. DEC)%B The full month name of the current field (January). December) %d two-bit days ( on.. to)%d Short time Format (mm/dd/yy)%e Short Format days (1.. to)%F file Time format same as%y-%m-%D%h Same as%b%H 24-Hour Hour (xx.. at)%I 12-Hour Hour ( on.. A)%j the first day of the year (001..366)%k short Format 24-hour hour (0.. at) %m Double-digit month ( on.. A)%M double-digit minutes (xx.. -) %r 12-hour time indication (time: minute: Second, double) A-Hour (hh:mm:ss [ap]m)%R 24-hour time representation (hours: minute, double) --Hour (hh:mm)%s from base time1970- on- on xx:xx:xxThe number of seconds to the current moment (a GNU extension) %T 24-hour time representation (HH:MM:SS)%u number expressed in weeks (starting from Monday1-7) %x Local date format (mm/dd/yy)%x local time format (%h:%m:%S)%y Two-bit year (xx.. About)%Y Year (1970...)
Shell Date Command Collation