hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Web Hosting Talk Tutorials : Hosting Security and Technology Tutorials : [How To] Delete some specific files from all subdirectories
Reply

Forum Jump

[How To] Delete some specific files from all subdirectories

Reply Post New Thread In Hosting Security and Technology Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old
Web Hosting Guru
 
Join Date: Nov 2005
Location: Palma de Mallorca, Spain
Posts: 259

[How To] Delete some specific files from all subdirectories


Hello,

Useful unix-command trick to quickly remove i.e. Thumbs.db files, WS_FTP.LOG files or *.fla files, recursively through directories.

It could be a real pain on a huge directory tree ;-)

Removing all *.fla files from /home/user/ and subdirectories...
Code:
# find /home/user/ -name \*.fla -ok rm {} \;
Removing all WS_FTP.LOG files from /home/user and subdirectories...
Code:
# find /home/user -name WS_FTP.LOG -ok rm {} \;
Removing all Thumbs.db files from /home/user and subdirectories...
Code:
find /home/user -name Thumbs.db -ok rm -f {} \;
Regards,

Juan



Sponsored Links
  #2  
Old
Web Hosting Master
 
Join Date: Jul 2004
Location: Texas
Posts: 687
Thank you for this VERY useful tutorial

  #3  
Old
Web Hosting Guru
 
Join Date: Nov 2005
Location: Palma de Mallorca, Spain
Posts: 259
Glad you find it useful. Don't know why can't edit the post...

Anyway, just a note...

Using "rm -f" will *not* ask for delete confirmation on every file, as shown on the third example.

Sponsored Links
  #4  
Old
WHT Addict
 
Join Date: May 2009
Posts: 156
You can also use:

find /home/user -name Thumbs.db | xargs rm

  #5  
Old
WHT Addict
 
Join Date: Jun 2008
Location: India
Posts: 129
yes, you can use the command suggested b sysgallery. Normally most of the techs will use that way to avoid again for cofirmation. You should be always safe to list the files by using find and then add he rm part........

  #6  
Old
Newbie
 
Join Date: Nov 2009
Posts: 6
Thank you, I found that extremely useful!

  #7  
Old
Web Hosting Master
 
Join Date: Apr 2009
Location: New York City
Posts: 4,152
So these are files that aren't needed? If im correct.

  #8  
Old
Newbie
 
Join Date: Oct 2009
Location: Bangalore
Posts: 12
Hi,

Your command was ok but change ok to exec and it will fine if you want to do it non interactively (CAREFUL COMMAND IS NON ITERATIVE)

For Removing all *.fla files from /home/user/ and sub directories..

-->>Following command will be the perfect . this will delete the files non interactively.


#find /home/user -name \*.fla -exec rm -rf {} \

-->> Removing all WS_FTP.LOG files from /home/user and subdirectories...(non interactively.)

#find /home -name WS_FTP.LOG -exec rm -f {} \;

-->>Removing all Thumbs.db files from /home/user and subdirectories...

find /home/user -name Thumbs.db -exec rm -f {} \;

  #9  
Old
Junior Guru Wannabe
 
Join Date: Nov 2009
Posts: 73
@8 that creates too many instances of exec, I prefer find /home/user -name Thumbs.db | xargs rm

__________________
>>> Guard your data with VPS Backup Solutions
>>> Resell Domains for profit

  #10  
Old
Newbie
 
Join Date: Jul 2010
Posts: 11
this helped me delete some stupid log files

  #11  
Old
WHT Addict
 
Join Date: Apr 2009
Posts: 106
Quote:
Originally Posted by diggo View Post
@8 that creates too many instances of exec, I prefer find /home/user -name Thumbs.db | xargs rm
You can even skip rm exec by using:

Code:
find /home/user -name Thumbs.db -delete
Then just "unlink()" syscall is issued (less overhead than fork() + exec() for /bin/rm).

__________________
Homer knows about his website downtime, what about you?
site-uptime.net site uptime monitor


  #12  
Old
New Member
 
Join Date: Aug 2012
Posts: 0
ya thanks it really useful

  #13  
Old
Newbie
 
Join Date: Jan 2013
Posts: 27
this is a useful tutorial i will recommend everyone to usethis if they need it!

  #14  
Old
Web Hosting Master
 
Join Date: Dec 2011
Location: Germany
Posts: 996
Using xargs is more simple than exec in my opinion.

Code:
find /path/to/dir -name "*.html" | xargs rm -f
To force delete every .html file in directory /path/to/dir and all following subdirectories.

__________________
r00t-Services.net | Anti DDoS, WAF, Security, Optimization, Troubleshooting.
In business since 2011 | Contact us: support[at]r00t-services.net
Affordable & Powerful DDoS Protection Service in Europe and the USA! (⌐■_■)--︻╦╤─ - - - DDoS

  #15  
Old
Newbie
 
Join Date: Jan 2013
Posts: 10
That's very useful tutorial. Thanks for this nice share.

Reply

Related posts from TheWhir.com
Title Type Date Posted
Single Tweet Brings Dropbox DMCA Takedown Policy into Spotlight Web Hosting News 2014-03-31 04:30:00
Egnyte Synchronizes Google Drive with Private Cloud Storage Web Hosting News 2013-07-17 12:36:21
Are You Prepared for Your Digital Afterlife? Blog 2013-06-27 16:28:32
Malwarebytes Launches Data Scan-and-Backup Service Web Hosting News 2013-05-07 14:51:03
Kim Dotcom Claims Megaupload Search Warrants Unlawfully Obtained by US Government Web Hosting News 2013-01-04 11:24:29


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
WHT Host Brief Email:

We respect your privacy. We will never sell, rent, or give away your address to any outside party, ever.

Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?