下面 hello 是开始时间, world 是结束时间

 

#!/bin/bash

START=$(date +%s);

hello="20160911 00"
world="20160911 03"

datebegin=`date -d "$hello" "+%Y%m%d%H"`
dateend=`date -d "$world" "+%Y%m%d%H"`

while [ "$datebegin" -le "$dateend" ]
do
echo $datebegin

echo $datebegin >> test.txt

middle=" "
before=`echo $datebegin | cut -c 1-8`
after=`echo $datebegin | cut -c 9-10`
tmp="$before$middle$after"

datebegin=`date -d "$tmp +1 hour " +%Y%m%d%H`

done
END=$(date +%s);
echo $((END-START)) | awk '{print int($1/3600)":"int($1%3600/60)":"int($1%3600%60)}'

 

相关文章:

  • 2021-12-12
  • 2021-05-22
  • 2022-01-12
  • 2021-11-28
  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-22
  • 2021-05-24
  • 2022-12-23
  • 2021-12-04
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案