Skip to content

Instantly share code, notes, and snippets.

@gardart
Created August 14, 2016 21:52
Show Gist options
  • Save gardart/29144df23a995263c0618906013d455a to your computer and use it in GitHub Desktop.
Save gardart/29144df23a995263c0618906013d455a to your computer and use it in GitHub Desktop.
Print out timestamp for each hour between date range
#!/bin/bash
# Print out timestamp for each hour between date range
begin_date=`date +%Y-%m-%d" "%H":00:00" -d "01/01/2016"`
end_date=`date +%Y-%m-%d" "%H":00:00" -d "01/30/2016"`
while [ "$begin_date" != "$end_date" ] ;
do
begin_date=`date -d "${begin_date}"'1 hour' +%Y-%m-%d" "%H":00:00"`
converted_date=`date -d "${begin_date}" +%Y%m%d%H`
echo $converted_date
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment