Skip to content

Instantly share code, notes, and snippets.

@tenomoto
Created September 15, 2016 04:16
Show Gist options
  • Save tenomoto/f09922cbd304a7b4f0c7ffdc797eb45e to your computer and use it in GitHub Desktop.
Save tenomoto/f09922cbd304a7b4f0c7ffdc797eb45e to your computer and use it in GitHub Desktop.
increment hour using date command
#!/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