I need to write a shell script that will filter out all files/directroies in a directory that are more than two months old and then copy those files to a new target location

ksh and bash are much the same critter, except that ksh is mostly Unix oriented. What OS are you running? You can also use perl or python (as mentioned by pyTony). You would probably use the 'find' command with the '-ctime' option (N*24 hours) to find the files in the time range you want, and then add the '-exec' option to 'find' to remove those files. Example (for files 3 days old):

find . -ctime 3 -exec rm -f {} \;

The find command is standard unix/linux stuff, so it should work on either system. So for files that have not been updated for at least 60 days (2 months more or less) use 60 for the -ctime option.

All that aside, do read the find command man page in detail. It will provide a lot of information about this and other options.

Edited 2 Years Ago by rubberman

This article has been dead for over six months. Start a new discussion instead.