Datetime - Fu
Con el comando date podemos conocer la fecha y hora actual:
Si quisiera mostrar el día, utilizo el comando date +%A:
Y si también quiero el día del mes, pongo %d:
Y si quiero saber el mes en que estamos, puedo poner %B:
Print UNIX time (seconds since Jan 1, 1970, 00:00:00 UTC)
Print GMT (Greenwich Mean Time) and local computer time
perl -le 'print scalar gmtime'
perl -le 'print scalar localtime'
perl -le 'print join ":", (localtime)[2,1,0]'
Print yesterday’s date
perl -MPOSIX -le '@now = localtime; $now[3] -= 1; print scalar localtime mktime @now'
Print date 14 months, 9 days and 7 seconds ago
perl -MPOSIX -le '@now = localtime; $now[0] -= 7; $now[4] -= 14; $now[7] -= 9; print scalar localtime mktime @now'
Prepend timestamps to stdout (GMT, localtime)
tail -f logfile | perl -ne 'print scalar gmtime," ",$_'
tail -f logfile | perl -ne 'print scalar localtime," ",$_'