Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to delete all files that start with ._, when I run this command:

me@me:/var/www/my/project$ sudo rm -Rvi ._*
rm: cannot remove `._*': No such file or directory

I'm pretty sure the . is causing problems, making it think I mean the current directory, what's the correct syntax to achieve this?

I know these files originated from my Mac, I need a way of nuking them :-)

Many thanks

Ben

share|improve this question
    
Hmm, I cannot seem to be able to reproduce your problem. (touch ._test, rm ._* works fine.) Maybe there's some other attributes that make the difference? Files beginning with a period aren't anything special, as it is the convention to 'hide' e.g. configuration files (~/.profile). –  Jawa May 26 '10 at 9:58

1 Answer 1

up vote 3 down vote accepted

You can try this:

find -name ._\* |xargs sudo rm -Rvi

or if your shell doesn't like that:

find |grep -e '^\._' | xargs sudo rm -Rvi

find without any arguments should just list everything.

share|improve this answer
    
Thanks! The first options worked fine when I did this: find -name ._\* |xargs sudo rm -v <-- left it with just verbose :-) –  Ben Everard May 26 '10 at 10:41
1  
This won't work if filenames contains spaces or newlines. To support those, use find -print0 and xargs -0. According to a colleague, removing all ._* files messes up SVN directories. He uses find . -type f -name "._*" -perm +w -delete, because ._* files in SVN are not writable. –  Sjoerd May 26 '10 at 12:02
    
@Sjoerd, that is indeed more elegant. –  Nathan Fellman May 26 '10 at 12:06

Your Answer

 
discard

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.