2

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

1
  • 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, 2010 at 9:58

1 Answer 1

3

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.

3
  • Thanks! The first options worked fine when I did this: find -name ._\* |xargs sudo rm -v <-- left it with just verbose :-) May 26, 2010 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, 2010 at 12:02
  • @Sjoerd, that is indeed more elegant. May 26, 2010 at 12:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .