The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-03-2006
pochaw pochaw is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 1
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 05:38 AM..
  #2 (permalink)  
Old 10-09-2006
msubbums msubbums is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 7
use the script

Hi,

use grep -v option before u run rm command

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


regards
Subbu Malepati
  #3 (permalink)  
Old 12-21-2007
nov_user nov_user is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 8
Question Thanks for the informatin

However I still want to delete the directory.

nov_user
  #4 (permalink)  
Old 12-21-2007
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 741
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.
  #5 (permalink)  
Old 12-22-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,422
you can use negation
Code:
# find /path -type f  -name "file_pattern_to_delete" ! -name "file_not_to_delete"   .....
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0