更新时间:2023-11-21 09:15:28
要获取所有的星期一,通过获取所有日期和周一过滤: p>
为'seq 0 365'
do date -d+ $ i day
done | grep Mon
当然,你也可以每星期一,持续增加7天。 >
I need to sort data on a weekly base and all i have are dates in a logfile. Therefore to sort out data per week i would like to create a list with the dates of all mondays for a given year. I have tried to work something out and the only idea i currently have is to use ncal with year and month as argument looping over all months and extracting all mondays. Isn't there a more efficient way?
To get all mondays, by getting all dates and filtering by Mondays:
for i in `seq 0 365`
do date -d "+$i day"
done | grep Mon
Of course, you could also take a monday and keep incrementing by 7 days.