Skip to content

Instantly share code, notes, and snippets.

@Hungsiro506
Last active February 5, 2019 02:55
Show Gist options
  • Save Hungsiro506/8e9921591f2fe15526411edaf4ce8a07 to your computer and use it in GitHub Desktop.
Save Hungsiro506/8e9921591f2fe15526411edaf4ce8a07 to your computer and use it in GitHub Desktop.
date -d '1 hour ago' '+%Y-%m-%d'
`Result` : 2017-11-13
date -d '1 hour ago' '+%Y-%m-%d %H'
Result : 2017-11-13 22
date -d '1 hour ago' '+%H'
22
date '+%H'
23
start=$(date -d '2 hour ago' '+%H')
end=$(date '+%H')
file_name="dns."$start":00:00-"$end":00:00.log"
date +'%Y' -> 2019
date + '%Y%m%d' -> 20190205
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment