Date issue

How to compare two input date string?

What I am basically trying to get here is get file names in a directory for a particular date range.
I would like to get the file data growth over a certain period of time.

When below code ran I am getting error - -sh: 20190929: No such file or directory

Any better tuned code would be helpful.

unset next_date
unset curr_date
next_date=20190101
curr_date=`date +%Y%m%d`
counter=0
while (  $next_date < $curr_date );
do
date_from=$(date -d "$next_date +$counter days" '+%Y%m%d')
echo $date_from
echo ">>>>>"$counter
((counter+=10))
echo $counter
date_to=$(date -d "$next_date +$counter days" '+%Y%m%d')
echo $date_to
#ls -lrt $(find /home/test/ -type f -newermt $date_from \! -newermt $date_to ) ## list files for specific range 
done

Shell omitted, bash assumed.

You are using single parentheses for the while condition and thus the < is interpreted as a redirection operator. Try with double parentheses for "Arithmetic Expansion".
Be aware that you created an infinite loop as next_date is not modified within the loop

I have made some correction. Please let me know if there is a better way to do it.

unset date_to
unset date_from
unset counter=15
date_to=$(date -d 2018-06-15 +"%Y%m%d")    
todate=$(date -d 2018-08-18 +"%Y%m%d")  
counter=0
while [ $date_to -lt $todate ]; #put the loop where you need it
do
 date_from=$(date -d "$date_to +1 days" '+%Y%m%d') 
 date_to=$(date -d "$date_from +$counter days" '+%Y%m%d')
 echo "date from"$date_from
 echo "date to" $date_to 
 ls -lrt $(find . -type f -newermt $date_from \! -newermt $date_to )
done

Now you do not increment counter.?

And what is unset counter=15 ?

More elegant is

 find . -type f -newermt $date_from \! -newermt $date_to -exec ls -lrt {} +

The {} + lets find collect all arguments and then run ls -rt with these arguments. This method safely handles file names with special characters.

Thanks for your reply. It should have been

unset counter
counter=15

Have made one more correction

date_from=$(date -d "$date_to +0 days" '+%Y%m%d')

to get file size for every 15 days of interval