From the given input and output files it is assumed the data is structed as follow:
cat -n FROM_DATE
1 20190105
2 20171124
cat -n TO_DATE
1 20190112
2 20171201
whereby the date has the format of YYYYmmdd
(and was i.e. created via date +%Y%m%d
).
To get a better idea about how it looks aggregated, lets print the two files side-by-side.
pr -m -J -t FROM_DATE TO_DATE
20190105 20190112
20171124 20171201
So it seems the questions is more about "How to expand the range of values which are splitted over two files and have the result aggregated?".
Following the hints from @steeldriver s comment and @Nortole s answer, a possible solution could look like:
#!/bin/bash
while read -r START_DATE && read -r END_DATE <&3; do
echo $START_DATE
for (( DATE="${START_DATE}"; DATE != END_DATE; )); do
DATE="$(date --date="${DATE} + 1 days" +'%Y%m%d')"
echo $DATE # which will be equals to END_DATE at the end
done
done < FROM_DATE 3<TO_DATE
Running the script will give the expected output:
20190105
20190106
20190107
20190108
20190109
20190110
20190111
20190112
20171124
20171125
20171126
20171127
20171128
20171129
20171130
20171201
– SpruceTips Nov 20 '17 at 19:55$ cat final_file | sort