Hi All,
I am new to scripting and am looking for some assistance setting up a script. Basically I need the script to scan a folder for the newest files and make a copy of those files, adding a month to the date stamp. I also need this script to delete the previously copied files to save space.
The files I need to scan and copy have the format
FileX_Sat_8hr00-08.file
The copied files (which also need to be deleted) have the format
FileX_03-MAR-2012_Sat_8hr00-08.file
I've seen examples of what I'm trying to do, such as deleting any files a day older for instance. These examples haven't done exactly what I'm looking for though.
Any assistance would be appreciated.
What is the criteria used for identifying files from a particular time range...
They will all have the date time stamp and extension in common. ex. Sat_8hr00-08.file
---------- Post updated 03-29-12 at 09:59 AM ---------- Previous update was 03-28-12 at 11:05 PM ----------
Could I use:
find . -mtime 1 -exec ls -d {} \; � xargs ls -ltr
To find the files created the day before?
ls -l | awk '{ print $6 }'
- this command separates the month column from the ls -l output.
- you could always read that output in to some sort of selection scenario of if statements. i guess that is crude, but i am relatively new to this too. if you could separate month output into numbers you could use a sort command and a command that picks the end or beginning values of the output. look for tail or head, i believe as the commands.