Created
September 15, 2016 04:16
-
-
Save tenomoto/f09922cbd304a7b4f0c7ffdc797eb45e to your computer and use it in GitHub Desktop.
increment hour using date command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
incrh () { | |
# Arguments | |
# 1: yyyymmddhh | |
# 2: dh | |
yyyymmddhh=$1 | |
dh=$2 | |
hour2sec=3600 | |
t0=`date -jf "%Y%m%d%H%M%S" ${yyyymmddhh}0000 "+%s"` | |
dh=`expr $dh \* $hour2sec` | |
t=`expr $t0 + $dh` | |
date -jf "%s" $t "+%Y%m%d%H" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment