PDA

View Full Version : bash script mv except today



tocleora
March 24th, 2007, 04:21 PM
I have a script that moves files to a backup drive every night. If it doesn't run however, I want to run it manually, however during the day there are new files I don't want moved, so I thought I could just build in to the script to only mv files that aren't for today. I could either do it mv ones that the file creation date isn't today, or the file names are like pl-YYYYMM so if there's anyway I could mv based on that... Any help would be appreciated!

monkeyking
March 24th, 2007, 05:28 PM
I haven't really thought it through,
but you can extract the modified date from the file with a small proggy like


ls -l | awk '{print $6}'


And from this you can compare with todays date.

Mr. C.
March 24th, 2007, 09:12 PM
Use:

find ... -mtime +1

to find files modified 1 or more days ago.

MrC