View Single Post
  #434  
Old 11-15-2007, 07:52 PM
OrigamiSensei OrigamiSensei is offline
Senior Member
 
Join Date: Jan 2006
Location: Resident micros wine geek
Posts: 1,017
Default Re: I Need to Move Up To Where My Raises Get Respect...

Good heavens, buzz, what are you trying to do with that code? If all you want to do is delete backup files that are more than a week old you should be able to use a variant of the find command:

find ~/play/backups -name "backup.[1-2][0-9][0-9][0-9][0-9][0-9][0-9][0-9].tgz" -ctime+8 -exec rm {}\;

The command finds all the files in the ~/play/backups directory named backup.date.tgz with YYYYMMDD dates later than 1900 that have not been changed in the last seven days and deletes them.

If you want a command line that finds the files and prompts you for an okay before deleting them then use the ok instead of the exec option like so:

find ~/play/backups -name "backup.[1-2][0-9][0-9][0-9][0-9][0-9][0-9][0-9].tgz" -ctime+8 -ok rm {}\;

Using all that code to do the job is scary unless there's something I'm missing.

1) Obtain the gloriously wonderful book called "UNIX Power Tools"
2) Avail yourself of the wisdom contained therein
3) ???
4) Profit

And boz, for that little comment on results vs maintainability may you be sentenced to a week of digging through disorganized, uncommented code trying to find a bug (I made the sentence relatively short because I like you).
Reply With Quote