Server Fault is a question and answer site for system and network administrators. 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

There's a lot of stuff about this on the Internet, but most of the examples there are contrived. How does one delete files that are really stubborn? e.g.,

$ find ./ -inum 167794
$ find ./ -inum 167794 -exec rm \"{}\" \;
rm: cannot lstat `"./\037\340\025K\021\004\310\377\377\377\377@\020\002"': Invalid or incomplete multibyte or wide character

share|improve this question
up vote 8 down vote accepted

Try removing the escaped double quotes. I believe rm thinks those are part of the filename.

find ./ -inum 167794 -exec rm {} \;
share|improve this answer
d'oh. Good spot. I never use unquoted variables in rm commands. I never noticed that find seems to be able to handle them fine. This actually works... weird... is it safe? touch important; touch "myfile -f important"; touch myfile; find "myfile -f important" -exec rm {} \; – mgjk Apr 13 '11 at 14:40
It's safe. You quote arguments to protect them from being touched by the shell. In this case, find is passing arguments directly to rm and they won't be interpreted/expanded by the shell. – MikeyB Apr 13 '11 at 15:19
man find advises to escape or quote {}, too. – sam hocevar Apr 13 '11 at 22:21

Better way with modern find (version 4.2.3 or later):

find ./ -inum 167794 -delete
share|improve this answer

If you want safe quoting for every shell I know, use this:

find ./ -inum 167794 -exec rm '{}' ';'
share|improve this answer
For every known shell, no masking of the braces is needed. Or earn some points on unix & linux. – user unknown Apr 13 '11 at 18:13
@user unknown: Or you could just read man find: Both of [{} and ;] might need to be escaped or quoted to protect them from expansion by the shell. – sam hocevar Apr 13 '11 at 22:19
If you had visited my link, you would have seen an emphasized citation citation of that. The text from the man page raised my interest, and I'm waiting since one month for somebody, who can name a current shell, where the argument is valid. might need is the keyword. Might or might not. Maybe I spend a bounty? – user unknown Apr 13 '11 at 22:36
@user unknown: I'm really sorry, I mistook the tone of your message and actually thought it meant I should earn points in order to be listened to. My apologies. That said, I tend to quote anything using { } because I don't want to have of think whether it is likely to get expanded. I agree {} is kinda special and I haven't met a shell that messed with it either. – sam hocevar Apr 13 '11 at 22:50
Ah no, I'm sorry for the ambiguous tone. I don't know how old the entry of find is, and don't know any shell, beside bash a bit, nor much OS' beside Linux. So I'm searching for the reason of that entry, because first I thought, it should be masked (from the manpage, and examples) and told everybody to mask it, got later curious, when seeing diverging examples which worked. – user unknown Apr 13 '11 at 23:58

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.