The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find excluding the hidden files arunkumar_mca UNIX for Advanced & Expert Users 3 01-27-2008 07:45 PM
how to display only hidden files useless79 Shell Programming and Scripting 5 09-19-2007 11:39 PM
Transferring hidden files with scp matrixmadhan UNIX for Dummies Questions & Answers 13 01-16-2007 12:00 PM
how to copy hidden files from one folder to another rajan_ka1 UNIX for Dummies Questions & Answers 1 11-07-2005 05:04 AM
Finding hidden files under mounted filesystems keelba UNIX for Dummies Questions & Answers 3 04-13-2005 11:59 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-03-2006
Registered User
 

Join Date: Oct 2006
Posts: 1
Stumble this Post!
Finding Hidden files and protecting the folder containing hidden files from deletion

Hi. I have a script which is deleting files with a particular extension and older than 45 days.The code is:
find <path> -name "<filename_pattern>" -mtime +45 -exec rm {} \;

But the problem is that some important files are also getting deleted.To prevent this I have decide to make a dummy hidden file in such folders which are not to be considered when this script is run.

Is this the right way to achieve the desired result???

If yes, then how can I do this??

If not, then what should be the ideal way??

Please.I need the solution urgently..

Thanx.

Last edited by pochaw; 10-03-2006 at 02:38 AM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-09-2006
Registered User
 

Join Date: Feb 2006
Posts: 7
Stumble this Post!
use the script

Hi,

use grep -v option before u run rm command

find arg|grep -v pat -exec rm {} \;


regards
Subbu Malepati
Reply With Quote
  #3 (permalink)  
Old 12-21-2007
Registered User
 

Join Date: Dec 2006
Posts: 6
Stumble this Post!
Question Thanks for the informatin

However I still want to delete the directory.

nov_user
Reply With Quote
  #4 (permalink)  
Old 12-21-2007
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 541
Stumble this Post!
Quote:
Originally Posted by pochaw View Post
Hi. I have a script which is deleting files with a particular extension and older than 45 days.The code is:
find <path> -name "<filename_pattern>" -mtime +45 -exec rm {} \;

But the problem is that some important files are also getting deleted.To prevent this I have decide to make a dummy hidden file in such folders which are not to be considered when this script is run.

Is this the right way to achieve the desired result???

If yes, then how can I do this??

If not, then what should be the ideal way??

Please.I need the solution urgently..

Thanx.

Can you show a sample of the <filename_pattern> and that of the important files.
Reply With Quote
  #5 (permalink)  
Old 12-21-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,542
Stumble this Post!
you can use negation
Code:
# find /path -type f  -name "file_pattern_to_delete" ! -name "file_not_to_delete"   .....
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0