I've been trying to get a script to print out a range of dates from a start date then the day after up to the present day.
Example:
Backup-2011-06-14
Backup-2011-06-15
Backup-2011-06-16
Had a idea below but doesn't even slightly work, any ideas?
start=$(date +%F --date="2011-06-14"开发者_C百科)
echo "$start"
current=$(date +%F)
echo "$current"
end=$(date +%F)
while [ "$start" != "$current" ]; do
    echo backup-$(( $(date --date="$start" +%F) + $(date +%s --date='1 day') ))
done
Date math in bash is difficult.  But the date command does support simple addition or subtraction from today's date.  So a different approach is necessary in your case.  First, determine the number of days for which you want to output these dates, then output the dates as they relate to today's date.
#!/bin/bash
days=$(( ($(date +%s)-$(date +%s --date="2011-06-14"))/86400 ))
while [ $days -gt 0 ]; do
    echo backup-$(date --date="-$days days" +%F)
    days=$(($days-1))
done
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论