SunQuest
           Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 11th, 2007, 03:52 PM
ovince ovince is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 14 ovince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 39 m 33 sec
Reputation Power: 0
Find files

hi all,

In dir1 and dir2 directories I have same subdirectories DH* like

--root
+ dir1
|
|
+ dir2


How to force find command to remove all "*.jpg" files from root. This does not work

find DH* -type f -name "*.jpg" -exec rm {} \;

thanks
oliver

Reply With Quote
  #2  
Old March 12th, 2007, 09:58 AM
veridicus veridicus is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 37 veridicus User rank is Lance Corporal (50 - 100 Reputation Level)veridicus User rank is Lance Corporal (50 - 100 Reputation Level)veridicus User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 8 h 8 m 56 sec
Reputation Power: 2
Try escaping the braces

-exec rm \{\} \;

I often have difficulty with executing find commands also.

Reply With Quote
  #3  
Old March 12th, 2007, 04:40 PM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,195 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 13 h 34 m 6 sec
Reputation Power: 252
It depends which shell you use - bash and sh do not have a built-in mechanism for expanding sudirectories. On the other hand zsh does it easily, which is why I use it as my default shell - I have never needed to use 'find' when running zsh. In zsh you can replace your script with this:

rm DH*/**/*.jpg

The ** expands out recursively through all subdirectories.

Dave

Reply With Quote
  #4  
Old March 12th, 2007, 04:46 PM
Matt1776's Avatar
Matt1776 Matt1776 is online now
Recovering Intellectual
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2006
Location: Orange County, CA
Posts: 872 Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level)Matt1776 User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 3 Weeks 3 Days 19 h 50 m 42 sec
Reputation Power: 329
Send a message via ICQ to Matt1776 Send a message via AIM to Matt1776 Send a message via MSN to Matt1776 Send a message via Yahoo to Matt1776 Send a message via Skype to Matt1776
Code:
find / -type f -print | grep .jpg | xargs -i rm -f {}
__________________
Bugs that go away by themselves come back by themselves
Never take life seriously, Nobody gets out alive anyway.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Find files


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway