15

Is there a command line to remove all "._foo.html" files in a directory on Unbuntu?

3 Answers 3

19
rm ./._*

more stuff since it must be at least 15 characters.

2
  • 1
    Also, this resource support.apple.com/kb/ht1629 may be helpful in preventing their creation in the first place.
    – Chris Nava
    Commented Jun 23, 2010 at 21:14
  • 1
    ./ is redundant.
    – kasperd
    Commented May 22, 2017 at 7:34
37

I use the following command to remove all of those annoying Apple files, but this one also does it recursively through all sub-directories, too:

# find . -iname '._*' -delete
6
  • 3
    +1 I came back to my question after I realized a recursive version of this command is what I really need. Thank you for adding the answer. Commented Jun 28, 2010 at 15:14
  • 1
    awesome. This one should be accepted as answer rather than the one above. Commented Mar 29, 2016 at 0:15
  • 5
    Or, more simply: find . -iname "._*" -delete Commented Jun 22, 2016 at 21:03
  • @ChristopherAltman, is this is really what you needed, you should accept this answer instead? Commented Aug 26, 2016 at 20:56
  • 2
    -name should be sufficient instead of -iname
    – rooby
    Commented Sep 5, 2016 at 4:06
1

I use James' answer so often during webdevelopment I created my own command in ~/.bash_profile

alias rmd=rmdotfiles
 rmdotfiles(){
   if [ -z "$1" ]; then
      local path=.
   else
      local path=$1
   fi

  find $path -iname '._*' -exec rm -rf {} \;
}

Remember to type . ~/bash_profile after editing the file to make it available.

EDIT: Example usage: rmd /path/to/dir

1

You must log in to answer this question.

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