Shell/Bash: bash get current date Example

By

Shell/Bash Example: This is the "bash get current date" Example. compiled from many sources on the internet by SimpleTutorials.org

bash get current date

# syntax
$(date)

# example (when running the command of "date")
echo $(date)

# OUTPUT: Mon May 11 13:20:57 SAST 2020
# To return a specific FORMAT, search "bash get date format"

echo date in bash

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}"



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

Others