15

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

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
Christopher Altman
  • 769
  • 4
  • 12
  • 20

3 Answers3

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
Khurram Raza
  • 103
  • 3
James
  • 1,021
  • 1
  • 6
  • 4
18
rm ./._*

more stuff since it must be at least 15 characters.

karmawhore
  • 3,865
  • 18
  • 9
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
    Also I found that for Mac OSX Users working locally you can use a dot_clean command https://apple.stackexchange.com/a/136801/193609 and https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/dot_clean.1.html – Ogier Schelvis Dec 01 '17 at 10:25