Skip to content

Instantly share code, notes, and snippets.

@ppdouble
Created July 20, 2023 06:28
Show Gist options
  • Save ppdouble/fe6090e3d814db353ed0a1e224f239d3 to your computer and use it in GitHub Desktop.
Save ppdouble/fe6090e3d814db353ed0a1e224f239d3 to your computer and use it in GitHub Desktop.
Generate time sequence in bash
for i in $(seq -w 1 02);
do
for j in $(seq -w 10);
do
for k in $(seq -w 16);
do
printf '%s:%s:%s,\t' "$i" "$j" "$k";
done
done
done
echo ""
echo "========================"
echo ""
for m in {1..2};
do
for n in {0..10};
do
for t in {0..16};
do
printf '%02d:%02d:%02d,\t' $m $n $t;
done
done
done
echo ""
echo "========================"
echo ""
starttime=$(date -d "2023-07-20 01:05:33" +'%s')
endtime=$(date -d "2023-07-20 06:39:20" +'%s')
while [ "$starttime" -le "$endtime" ]
do
res=$(date -d @$starttime +'%H:%M:%S')
resfull=$(date -d @$starttime +'%Y-%m-%d %H:%M:%S')
printf "%s, %s\t" "$res" "$resfull"
starttime=$(($starttime+600))
done
echo ""