![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multiple Files deletion in perl | pulkit | Shell Programming and Scripting | 1 | 02-12-2008 05:55 AM |
| Finding Hidden files and protecting the folder containing hidden files from deletion | pochaw | Shell Programming and Scripting | 4 | 12-22-2007 01:33 AM |
| conditional deletion of log files | sonali007 | UNIX for Dummies Questions & Answers | 3 | 10-03-2007 11:56 AM |
| Script for automatic deletion of old files | vivek_scv | Shell Programming and Scripting | 4 | 09-09-2007 01:57 AM |
| Deletion of log files. | Geeta | UNIX for Dummies Questions & Answers | 1 | 06-23-2006 07:04 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Regarding deletion of old files
Hi,
I have a list of directories which contain old files that are to be deleted. I put the list of all directories in a txt file and it is being read by a script Iam searching for the files older than 60 days using mtime and then deleting it But all the files are getting deleted irrespective of mdate.iam providing the script code here #! /bin/sh #setting the date DATE='date + "%y%m%d"' cat param.txt| while read DIR TIME do #Check if the directory is present if [ -d "${DIR}" ] then echo "$DIR is a directory on this machine" echo "Time Limit:$TIME" echo "looking for files older than $TIME days to be deleted from $DIR" find $DIR -type f -mtime $TIME |xargs rm -f echo "older files are now deleted successfully" else echo "$DIR is not a directory.please check again" fi done Is there any thing wrong with the find command my datafile is like this /var/home/.... +60 /home/chidvilas/.. +60 But the script is removing all files irrespective of mtime?? CAn anyone suggest on this?? |
|
||||
|
Or do it all in one go
find <the path you want to check> -ctime -60 -exec rm {} \; You would want to be very, very sure of where you run this, as most operating system files would be older than 60 days. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|