Take the 2-minute tour ×

I want to run a command similar to this where AVI files older than 7 days will be deleted:

find "/home/user/videos folder/*.avi" -mtime +7 -exec rm -f

But as you can see, the videos folder has a space so I had to put that path in quotes. But, will the asterisk still do its job to find all AVI files, or will Linux now think the asterisk is the actual filename now?

Let's just assume I didn't want to remove the space in the path by renaming the folder.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You need to reformat your command a bit for it to work.

Try this:

find "/home/user/videos folder" -name "*.avi" -mtime +7 -exec rm -f {} \;

Or, in GNU find, to achieve the same thing without -exec:


The first argument to find is the folder to look in - you shouldn't try and put your entire filter in here, just the starting point. Then use -name to tell it what pattern to look for. You can try this without the -exec or -delete first until you are satisified, then you won't do any damage by trying it.

Enclosing an argument in quotes basically stops the shell from messing with it. If you use -name *.avi, then the argument that find will see could be anything, because the shell will parse it (and replace it with the contents of the current directory that end in .avi) before calling find. This is usually bad and will lead to unexpected results. find knows how to parse * itself.

share|improve this answer
You missed the final {} \;. Also, you could use -delete with GNU find, instead of -exec rm {} \;. –  enzotib Dec 10 '11 at 15:49
Thank you very much! That has answered my question exactly. This works for me on Ubuntu Server: find "/home/user/videos folder" -name "*.avi" -mtime +7 -exec rm -f {} \; –  nLinked Dec 10 '11 at 16:02

Your Answer


