Delete files by file type recursively

  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

I just want to make sure I'm not going to screw up royally before I actually do this. On my main file server, I have about 200 users with home directories, and inside those I want to delete all mp3 files. So if I:

BASH Code: [ Select ]
cd /home
 
rm -rf *.mp3
 
  1. cd /home
  2.  
  3. rm -rf *.mp3
  4.  


Will that only delete files with the .mp3 extension regardless of which folder it is in? I always get kind of nervous when I am doing rm -rf and I don't want to muck everything up.
  • kc0tma
  • o|||||||o
  • Web Master
  • User avatar
  • Posts: 3318
  • Loc: Trout Creek, MT

Post 3+ Months Ago

Never mind, I found a way that works painlessly.

BASH Code: [ Select ]
find /home -iname "*.mp3" -exec rm {} \;

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 76 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.