Shell/Bash: shell script current time Example

By

Shell/Bash Example: This is the "shell script current time" Example. compiled from many sources on the internet by SimpleTutorials.org

shell script current time

date +'FORMAT'
 
### mm/dd/yyyy ###
date +'%m/%d/%Y'
 
## Time in 12 hr format ###
date +'%r'
 
## backup dir format ##
backup_dir=$(date +'%m/%d/%Y')
echo "Backup dir for today: /nas04/backups/${backup_dir}"

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..."
# command to backup scripts goes here
# ...



* Summary: This "shell script current time" Shell/Bash Example is compiled from the internet. If you have any questions, please leave a comment. Thank you!

Others