LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-06-2007, 08:30 AM   #1
adam_blackice
Member
 
Registered: Apr 2006
Location: /*Egypt */ //cairo
Distribution: Ubuntu 7.04 , SLED 10 , Fedora , RHEL 5
Posts: 312

Rep: Reputation: 32
ideas for refining this script


this is script to remove directories that exist equal or older than 3 days


Code:
 #!/bin/bash

echo "Enter the name of the dir you want to check"

read dir

if [ -d $dir ]

then

        find $dir -type f -a -atime +10 -exec rm -i {} \;
else

echo "The Directory doesn't exist"

fi

#END
if any one has ideas that i can refine script with please give me a feedback with these refinements .


Thanks .

Last edited by adam_blackice; 09-06-2007 at 08:37 AM. Reason: the title of the thread was wrong
 
Old 09-06-2007, 01:42 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
I think you want -mtime +3 not -atime +10

And a directory is -type d

Plus, rm -R -f $dir/* will do the same things as long as you check the mtime on the directory.

Last edited by jim mcnamara; 09-06-2007 at 01:44 PM.
 
Old 09-10-2007, 10:43 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
... and to remove a dir it's rmdir
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie's script ideas cyjetsu Linux - Newbie 4 01-07-2007 12:21 PM
Ok so my script is not working, any ideas? mago Linux - General 8 03-30-2005 11:13 PM
sed script help/ideas rjcrews Programming 2 07-30-2004 02:59 PM
shell script ideas marigb Linux - Newbie 8 04-24-2004 02:16 AM
ideas for a perl script LAMP_User Programming 3 03-18-2004 04:18 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration