I have the following problem in a Bash script:
On execution of the script a Zenity popup box opens to ask how many date entries should occur. If for example 3 is entered then a further 3 Zenity boxes are opened up (one after another) to ask for a date entry.
From this I am able to generate two variables ($tvar and $date_entry_number). $date_entry_number captures the amount of dates entered and $tvar captures all dates entered, separated by white-space. In the case of $date_entry_number = 3, $tvar might be = '2020-07-02' '2020-07-03' '2020-07-04'.
What I am trying to do is create variables containing individual dates from $tvar, such as $tvar1='2020-07-02' $tvar2='2020-07-03' $tvar3='2020-07-04' base on $date_entry_number which could be any number. This would mean that there could be any number of dates in $tvar.
My thinking is that I would need a for loop as you can see in the script below but I am not sure how to do this properly. Can someone please help?
#!/bin/bash
date_entry_number="$(zenity --entry --text "ENTER number of date_entries:" --entry-text "1")"
a=1
tvar=$(until
[[ $date_entry_number -lt $a ]]
do
date_out="$(zenity --calendar
--title="Select a Date"
--text="Click on a date to select that date."
--date-format="'%G-%m-%d'")"
var="${date_out}"
echo $var
let a++
done)
echo $tvar
echo $date_entry_number
for i in {1..$date_entry_number}
do
nvar{1..$tvar}
done
echo $nvar{1..$tvar}