Link to home
Start Free TrialLog in
Avatar of simonenticott
simonenticottFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Simple Linux script question about deleteing files after x days

Hi,

I know my around Linux but i'm a novice when it comes to shell scritping.

I want to add a few lines to a script that will find all files older than x days and delete them,
it must start at a directory i specifiy and work on all subdirectories below.
Some of the filenames may contain spaces and mixed case letters etc.
I don't want to use perl or anything other than standard shell script commands.

Background:
Its a script to run on an FTP server that our mobile staff use for transferring stuff to and from the office.  In the office the FTP server is just a windows share and so people tend to use windows filenames - hence the spaces etc.  Of course they just wont keep the area tidy so i want to add a script that will remove everything older than 4 or 5 days.

The FTP server is running under Fedora Core 3.

thanks,

Simon.

Avatar of danny_ebbers
danny_ebbers

#!/bin/sh
find . -ctime +$1 -exec rm -rf {} \;




----------------------------------
for testing you should first use this

find . -ctime +$1 -exec echo Marked for deletion: {} \;



ASKER CERTIFIED SOLUTION
Avatar of danny_ebbers
danny_ebbers

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of simonenticott

ASKER

Thanks danny, i've spent ages trying to figure this out !

Simon,