La commande date permet l'affichage et la configuration la date et l'heure du système.
date
root@ubuntu:~# date Fri Feb 6 10:35:11 CET 2015 root@ubuntu:~# date -d "yesterday" Thu Feb 5 10:35:11 CET 2015 root@ubuntu:~# date -d "1 day ago" Thu Feb 5 10:35:11 CET 2015 root@ubuntu:~# date -d "2 day ago" Wed Feb 4 10:35:11 CET 2015 root@ubuntu:~# date -d "-2 day" Wed Feb 4 10:35:11 CET 2015 root@ubuntu:~# date +%Y-%m-%d -d "yesterday" 2015-02-05 root@ubuntu:~# date +"%Y-%m-%d %H:%M:%S" -d "Mon Oct 1 10:14:00 2018" 2018-10-01 10:14:00 root@ubuntu:~# date +"%Y-%m-%d %H:%M:%S,%3N" 2018-09-28 16:54:41,349
root@ubuntu:~# for HH in $(seq -f %02g 6 19) do for MM in $(seq -f %02g 0 20 59) do dateStart="2024-06-27 ${HH}:${MM}:00" dateStartString=$(date -d "${dateStart}" "+%Y%m%d%H%M%S") dateStartSecond=$(date -d "${dateStart}" "+%s") # dateStopSecond is 20 minutes (1200seconds -1) later let "dateStopSecond=${dateStartSecond}+1199" dateStop=$(date -d @${dateStopSecond} +"%Y-%m-%d %H:%M:%S") dateStopString=$(date -d "${dateStop}" "+%Y%m%d%H%M%S") echo "--start ${dateStartString} --stop ${dateStopString}" done done --start 20240627060000 --stop 20240627061959 --start 20240627062000 --stop 20240627063959 --start 20240627064000 --stop 20240627065959 --start 20240627070000 --stop 20240627071959 --start 20240627072000 --stop 20240627073959 --start 20240627074000 --stop 20240627075959 --start 20240627080000 --stop 20240627081959 ...
root@ubuntu:~# cp -pv fichier.ext fichier.ext.$(date +"%Y%m%d%H%M%S")