Results 1 to 15 of 15
-
01-04-2007, 09:40 AM #1Web Hosting Guru
- Join Date
- Nov 2005
- Location
- Palma de Mallorca, Spain
- Posts
- 263
[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 {} \;
Code:# find /home/user -name WS_FTP.LOG -ok rm {} \;
Code:find /home/user -name Thumbs.db -ok rm -f {} \;
Juan
-
01-04-2007, 05:02 PM #2Web Hosting Master
- Join Date
- Jul 2004
- Location
- Texas
- Posts
- 688
Thank you for this VERY useful tutorial
-
01-04-2007, 05:10 PM #3Web Hosting Guru
- Join Date
- Nov 2005
- Location
- Palma de Mallorca, Spain
- Posts
- 263
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.
-
08-11-2009, 04:44 AM #4WHT Addict
- Join Date
- May 2009
- Posts
- 157
You can also use:
find /home/user -name Thumbs.db | xargs rm
-
08-24-2009, 05:55 AM #5WHT Addict
- Join Date
- Jun 2008
- Location
- India
- Posts
- 130
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........
-
11-02-2009, 03:28 PM #6Newbie
- Join Date
- Nov 2009
- Posts
- 7
Thank you, I found that extremely useful!
-
11-15-2009, 09:15 PM #7Web Hosting Master
- Join Date
- Apr 2009
- Location
- New York City
- Posts
- 5,169
So these are files that aren't needed? If im correct.
-
12-06-2009, 01:42 AM #8Newbie
- Join Date
- Oct 2009
- Location
- Bangalore
- Posts
- 13
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 {} \;
-
01-05-2010, 10:48 AM #9Junior Guru Wannabe
- Join Date
- Nov 2009
- Posts
- 75
@8 that creates too many instances of exec, I prefer find /home/user -name Thumbs.db | xargs rm
-
07-10-2010, 12:13 AM #10Newbie
- Join Date
- Jul 2010
- Posts
- 13
this helped me delete some stupid log files
-
11-20-2012, 05:13 PM #11WHT Addict
- Join Date
- Apr 2009
- Posts
- 107
Homer knows about his website downtime, what about you?
site-uptime.net site uptime monitor
-
12-18-2012, 06:04 AM #12New Member
- Join Date
- Aug 2012
- Posts
- 2
ya thanks it really useful
-
01-11-2013, 02:26 PM #13Newbie
- Join Date
- Jan 2013
- Posts
- 28
this is a useful tutorial i will recommend everyone to usethis if they need it!
-
01-11-2013, 02:37 PM #14Digital Marketing Strategist
- Join Date
- Dec 2011
- Location
- Germany
- Posts
- 1,180
Using xargs is more simple than exec in my opinion.
Code:find /path/to/dir -name "*.html" | xargs rm -f
➤ Inbound Marketing & real SEO for web hosting providers
✎ Get in touch with me: co<at>infinitnet.de
-
02-05-2013, 08:46 AM #15Newbie
- Join Date
- Jan 2013
- Posts
- 14
That's very useful tutorial. Thanks for this nice share.