bash get time code example
Example 1: datetime echo shell script
$(date '+%d/%m/%Y %H:%M:%S')
Example 2: shell script current time
date +'FORMAT'
date +'%m/%d/%Y'
date +'%r'
backup_dir=$(date +'%m/%d/%Y')
echo "Backup dir for today: /nas04/backups/${backup_dir}"
Example 3: shell script current time
now="$(date)"
printf "Current date and time %s\n" "$now"
now="$(date +'%d/%m/%Y')"
printf "Current date in dd/mm/yyyy format %s\n" "$now"
echo "Starting backup at $now, please wait..."
Example 4: bash time
date
Example 5: unix get time
user@machine:~$ date
Tue Jan 12 09:22:56 UTC 2021
Example 6: bash time command
time [command]
time ls