I have a start time and an endtime and want to increment the times. Basically
the month and day have to be incremented in a loop to create two strings, stm and
etm defining the start and end times.
I have started doing this bash details for constructing the start and end strings.
# Covering months May to December
for m in {5..12}; do
mth=$((mth+1))
echo "mth: $mth"
for dy in {1..30}; do
day=$((day+1))
echo "day: $day"
done
echo ""
done
# Covering months Jan to April
for m in {1..4}; do
mth=$((mth+1))
echo "mth: $mth"
for dy in {1..30}; do
day=$((day+1))
echo "day: $day"
done
echo ""
done
Sadly I don't know what you are trying to achieve as output here. Can you explain?
Is it homework perhaps? There is a special forum for this.
I could guess that you want a sequence of dates where the month and the day add one each iteration but I'm not sure why.
.... or is it that you want every combination of valid dates for these months. In this case, you are missing the 31st when that occurs and including the 30th February, and taking no account of a leap year.
Would the output from cal be useful?
Can you explain the purpose of this in context? There may be a better way.
This is all interesting, but it still doesn't tell us what you are trying to do nor what output you are trying to produce. Robin asked you several questions in post #2 in this thread that you have not answered.
In what way does producing a list of months 2 through 13 on days 2 through 31 help you define two strings referencing a start time and an end time for an unspecified event.
Knowing that you don't mind creating invalid dates and don't mind losing some of your seismological data is interesting, but it still doesn't tell us what output you're trying to produce nor what that output represents in the real world.
We want to help you reach your goal, but if you don't explain what you're trying to do we are left guessing at what you might be trying to do and are highly unlikely to make a guess that will be of any use to you. Please help us help you!