Deleting files created before two days ago

Dear All:

I want to build a shell that delete files created two or more days ago ... I think it could be built using a special command with ls or grep, I'd apreciate any help from you guys

I have a lot of log files from november, december, january and this tool will help me a lot

The files are in different directories, but all of them under my $HOME directory

Cheers

Jose

You could use the find command to look for files modified or accessed 2 days ago and remove them. You can do a man find to get more details. Here is an ex:
syntax:
find <directory_name> -name <filename> -mtime +2 -exec rm {} \;

find /ora_export -name "exp*" -mtime +2 -exec rm {} \;

The above command looks for filenames starting with exp which were created/modified 2 days ago and removes them.
You could put it in a shell program also.
mtime means modified time
atime means access time
you could use the one applicable to you.

Hope this helps.

Following command will find and list files older than 2 days from right now, not on clean calendar day divisions, and of course it also searches subdirectories:

find mydir -type f -mtime +2 -exec ls -ld {} \;

To remove them, change the ls -ld to rm -f

(Sorry knarayan, you covered it well, but your reply was not there when I started my reply)

Thank you very much guys, I implemented this procedure and works very fine !!!

Sorry for not send my response before, my company replaced our web server ....

Thanks a lot

Jose