You are not logged in.

#1 2009-06-07 12:47:31

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

syntax to delete all .ogg files recursively [solved]

I'm wondering how to go about recursively deleting all .ogg files from an entire directory structure.

Would something like this do it?

find /mount/point -name '*.ogg' -type f -exec rm '{}' \;

Last edited by graysky (2009-06-07 17:08:18)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2009-06-07 12:52:17

seppo0010
Member
From: Buenos Aires
Registered: 2009-02-14
Posts: 12

Re: syntax to delete all .ogg files recursively [solved]

You can create a folder and test it, before running it seriously.
I've done it more than once like this

rm -f `find /mount/point -name \*.ogg`

Offline

#3 2009-06-07 12:59:28

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: syntax to delete all .ogg files recursively [solved]

Why not just

find /path/ -name *ogg -exec rm {} \;

Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#4 2009-06-07 13:46:41

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: syntax to delete all .ogg files recursively [solved]

find . -name "*.ogg" -delete

Edit: if you use bash4 or zsh

for f in **/*.ogg; do rm "$f"; done

Edit: Use at your own risk, test before you try it on real data.

Last edited by Mr.Elendig (2009-06-07 13:48:27)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#5 2009-06-07 15:34:38

kludge
Member
Registered: 2008-08-03
Posts: 294

Re: syntax to delete all .ogg files recursively [solved]

B wrote:

Why not just

find /path/ -name *ogg -exec rm {} \;

damn.  is there an o'reilly book about 'find' yet?  there should be.  i read the man page not too long ago and realized that it's a whole damned file-manager unto itself.


[23:00:16]    dr_kludge | i want to invent an olfactory human-computer interface, integrate it into the web standards, then produce my own forked browser.
[23:00:32]    dr_kludge | can you guess what i'd call it?
[23:01:16]    dr_kludge | nosilla.
[23:01:32]    dr_kludge | i really should be going to bed.  i'm giggling madly about that.

Offline

#6 2009-06-07 15:35:55

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: syntax to delete all .ogg files recursively [solved]

kludge wrote:
B wrote:

Why not just

find /path/ -name *ogg -exec rm {} \;

damn.  is there an o'reilly book about 'find' yet?  there should be.  i read the man page not too long ago and realized that it's a whole damned file-manager unto itself.

`man find` and search for '-delete'

Last edited by Mr.Elendig (2009-06-07 15:36:18)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#7 2009-06-07 15:44:42

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: syntax to delete all .ogg files recursively [solved]

With zsh and probably bash 4:

rm /mount_point/**/*.ogg

Last edited by lucke (2009-06-07 15:47:06)

Offline

#8 2009-06-07 17:09:10

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: syntax to delete all .ogg files recursively [solved]

Thanks for the replies, all.  My original line did work.  Maybe I need to have a look at bash4 since the code is a bit leaner, but I am no bash 3 expert by any means smile


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#9 2009-06-07 18:20:53

jordz
Member
Registered: 2006-02-01
Posts: 248

Re: syntax to delete all .ogg files recursively [solved]

With the GNU find you can just use -delete smile

Offline

Board footer

Powered by FluxBB