simonenticott
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks danny, i've spent ages trying to figure this out !
Simon,
Simon,
find . -ctime +$1 -exec rm -rf {} \;
--------------------------
for testing you should first use this
find . -ctime +$1 -exec echo Marked for deletion: {} \;