Like most developers these days I consider myself platform agnostic. This has led me into several jobs where I develop exclusively on OS X, but store and stage work on non-AFP server volumes. Of course this is no problem but it does come with its own set of idiosyncrasies.
One such annoyance is the automatic creation of ‘dot underscore’ files. These metafiles quickly litter any non-HFS+ formatted drive (a common issue in a mixed-platform environment), and are irritating when it comes to tasks such as version control (although you can have them ignored) and archiving directories with tar. By far the easiest method for disposing of these files in OS X is via a tool called BlueHarvest. The only downside is it’ll cost you – $14.95 USD at the time of writing.
So, is there a free alternative? Well, yes – it does however involve a little bit of work. You can recursively remove the offending dot underscore files with the following one-liner:
find . -name '._*' -print | xargs rm
If you find that you are having issues due to files containing spaces, you can get around this by using the following command instead:
find . -name '._*' -printf \'%h/%f\'\\n | xargs rm
This will find all matching files recursively that match the glob pattern ‘._*’ and print them, then each result of this command is piped through ‘rm’. The other common sight is the .DS_Store file. These can be removed using the same snippet as above (switching ‘._*’ for ‘.DS_Store’), or you can suppress the automatic creation of resource fork files (.DS_Store) with this snippet:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true