how to print the date in linux code example
Example 1: get current server time centos
timedatectl
Example 2: bash get current date
$(date)
echo $(date)
Example 3: 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 4: shell script current time
#!/bin/bash
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..."