Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My queston is kind off a basic * nautilus at time cant do well at recursive search & related operations...

I want to search files having name libre in them & then delete them... I am half done here & cant find a relaiable way to delete files especially when filenames have white spaces in them...

find -iname *libre*

this will search the files but lets say a file is 'Libre Office Word' now it has white spaces can you guide how to delete such files too?

share|improve this question
up vote 5 down vote accepted

You can use the -delete option if your version of find supports it or you can use rm in the -exec options.

find -iname '*libre*' -delete       # GNU find
find -iname '*libre*' -exec rm {} + # POSIX

Note that you should quote the pattern. This prevents the shell from expanding it prior to being passed to the find command.

share|improve this answer
I'm not sure if OP wants also uppercase letters in the name (by the example given). – vonbrand Jan 26 '13 at 5:46
@vonbrand my understanding is the OP wanted "Libre Office Word' to match, but was using some method of deletion (such as xargs or a for loop) that broke on files with spaces. – jordanm Jan 26 '13 at 5:49
@jordanm yes you identified my real position. OK so the -delete flag worked even for whitesapces. How can I also pass a file extension to this search I mean search for libre & *.desktop – nightcrawler Jan 26 '13 at 6:11
-iname is not POSIX. -delete is not POSIX but is not exclusive to GNU find. – Stéphane Chazelas Jan 26 '13 at 7:58
Also note that -delete deletes (non-empty) directories, while rm wouldn't. -delete (both with GNU and FreeBSD finds at least) implies -depth. – Stéphane Chazelas Jan 26 '13 at 8:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.