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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
move files using wildcard onlyjayaram Shell Programming and Scripting 1 07-24-2007 02:02 AM
copying to multiple directories using wildcard logic0 UNIX for Dummies Questions & Answers 4 05-22-2007 09:09 AM
Disable wildcard Rock Shell Programming and Scripting 5 01-24-2007 09:36 AM
Wildcard comparison rdudejr Shell Programming and Scripting 2 08-02-2006 06:09 PM
wildcard abhi UNIX for Dummies Questions & Answers 13 02-15-2005 01:43 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-27-2001
Neko Neko is offline
Registered User
  
 

Join Date: Jun 2001
Posts: 3
Find wildcard .shtml files in wildcard directories and removing them- How's it done?

I'm trying to figure out how to build a small shell script that will find old .shtml files in every /tgp/ directory on the server and delete them if they are older than 10 days...

The structure of the paths are like this:
/home/domains/www.domain2.com/tgp/
/home/domains/www.domain3.com/tgp/
/home/domains/www.domain4.com/tgp/
/home/domains/www.domain5.com/tgp/

So I've got 220 domains on this one box and in each of those domains I've got a directory called /tgp/ ...in /tgp/ directory I have hundreds of old .shtml files that I need to delete.

If I use this command will it work or will it cause any damage?

find /tgp -mtime +10 -name "*.shtml" -exec rm

If this is not the best way to do this, which way should I handle this and what command could take care of this?
  #2 (permalink)  
Old 06-27-2001
Neo's Avatar
Neo Neo is online now Forum Staff  
Administrator
  
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 6,724
You are on the right track. However two things:


(1) Suggest you use the <B>-regex</B> switch of find for pattern matches (and not the -name switch with wildcards). That is how I do it, using regular expressions.

(2) Suggest you execute/test your <B>-exec</B> switch with mv (move) to a temporary directory before executing rm (remove) to insure things work as planned This is always a good practice, regardless of the level of skill and confidence. Moving files to a temporary directory before deleting has a lot of benefits, most of all, you will not ruin your day with a typo or other mistake!!
Closed Thread

Bookmarks

Tags
regex, regular expressions

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 06:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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