How are your files organised? If there is a difference in the filename to clearly mark a Sunday file, then it should be easy but you would need to explain a little more what files you have first.
Can you show us the output from an ls -l of the files in question that you want to work with?
I think rbatte1 was after a clearer explanation of the intended target files' names. Me, I couldn't tell what you're after when reading both your posts.
I agree with RudiC, your input and list of files do not match and not clear .
Did you mean to list the files ?
man find ( search for -printf )
%Tk File's last modification time in the format specified by
k, which is the same as for %A.
a locale's abbreviated weekday name (Sun..Sat)
Here is the example, i tried to simulate. Hope it helps.
find . -type f -printf '%Ta\t%p\n' | grep Sun | tail -2
output:
Sun ./f2
Sun ./f1
Change the weekday name and number as per your need.
If this is not what you want, please provide input files , expected output whether you want to list last four sunday based on date information present in filename or 'file modification time' etc.
The backup happens every night.
The file name shows the date.
I have a script that keeps the last 5 files.
I want it to also keep the last 4 Sundays on top of the last 5 files.
There's a rich abundance of backup schemes on the net, and even in these forums you might find some that you could adapt to suit your needs.
Looks like you want to save sort of 5 daily backups and another 4 weekly ones?
How about saving the Sundays' backups in a separate directory and keep the latest 4, resp. delete those more than 4 weeks old?
In an earlier OS, using a backup package to create the file I used cron to step it through the directory queue:
backup file created at 3:01 AM
at 4:01 I cleared the backup4 directory
at 4:15 I moved backup3 contents to backup4
at 5:15 I moved backup2 contents to backup3
at 6:15 I moved backup1 contents to backup2
at 7:15 I moved the current backup to backup1
for the weekly it would have been a matter of copying the Sunday backup to a similar queue.
It helped that I put the entire backup system on it's own file system on it's own hard drive and that the daily backup was burned to CD first. Over 15 years and as many as 6 machines I only have had 1 issue where this failed me and I had to reconstruct from CD.