Reputation: 1607
Can anyone help me to add only the hour part in below date/time format:
For instance, starting with 20 August 10:00am
2016-08-20-10
I would like to increment only the hour part, so that I get:
2016-08-20-11
2016-08-20-12
2016-08-20-13
etc.
stopping at a specified date, such as 2016-08-21-08
Upvotes: 0
Views: 440
Reputation: 1607
I figured out the solution to my own question. See below:
date=(2016-08-23-0 2016-08-23-1 2016-08-23-2 2016-08-24-0 2016-08-24-1 2016-08-24-2)
date_arr=(2016-08-23-2 2016-08-24-2)
for ((i=0; i<"${#date[@]}"; i++))
do
if [[ " ${date_arr[*]} " == *"${date[i]}"* ]]
then
for ((j=0; j<=3; j++))
do
echo "${date[i]}$j"
done
else
for ((k=0; k<=9; k++))
do
echo "${date[i]}$k"
done
fi
done
Upvotes: 1