Results 1 to 5 of 5
Hi Guys,
I am new to unix, I am looking for a script to delete files older than 7 days but i also want to exclude certain directories (like arch,log ...
- 01-03-2011 #1Just Joined!
- Join Date
- Jan 2011
- Posts
- 2
delete files older than 7 days
Hi Guys,
I am new to unix, I am looking for a script to delete files older than 7 days but i also want to exclude certain directories (like arch,log .....) and also some files with extensions ( like .ksh, .ch, ..............) in directories and sub directories
Thanks in advance
sunny
- 01-03-2011 #2Just Joined!
- Join Date
- Dec 2010
- Location
- India
- Posts
- 45
U can get the files 7 days older by using find command with -mtime option .
and then from the list of file use regular expression and delete the files that is not having .csh or .ksh extention.
you try out and write the script . if there is any problem we will correct that.
for reference check man find .
- 01-03-2011 #3Just Joined!
- Join Date
- Jan 2011
- Posts
- 2
Hi piyu,
I have written the command it is checking in the directory only but not checking in sub directories
find tdarch/* -prune -type f ! \( -name "*.ksh" -o -name "*.sh" -o -name "*.c" \) -mmin +1 > tdlog/4.logLast edited by sunnyece51; 01-03-2011 at 02:42 PM. Reason: Modification
- 01-03-2011 #4Just Joined!
- Join Date
- Jun 2010
- Posts
- 6
man find
-prune prevents going into subdirectories.
Just get rid of that option and try again.
- 01-04-2011 #5Just Joined!
- Join Date
- Dec 2010
- Location
- India
- Posts
- 45
dufftime told you the problem but i want to suggest one thing. before writing any command just go through the man page of that command and ensure that whatever options you are using you know them why are u using that
happy learning


Reply With Quote