why does OSX add extra '._<filename>' when I tar a directory?

I'd just like to know why if I "tar -czf" a file/directory, osx adds a: ._ for each file? I see these when I untar in linux. Or when I work with the uncompressed project in eclipse as it doesn't like them at all. I use 10.7.5.


OS X's tar uses the AppleDouble format to store extended attributes and ACLs. tar and Archive Utility also know how to convert the ._ files back to the native formats, but the ._ files are kept if the archive is extracted on another platform or on a non-HFS volume.

You can usually just tell tar to remove the metadata by setting COPYFILE_DISABLE to some value:

$ xattr -l file.jpg
com.apple.quarantine: 0002;50d20c48;Tweetbot;
$ tar -cf 1.tar file.jpg 
$ tar -tf 1.tar 
./._file.jpg
file.jpg
$ COPYFILE_DISABLE=1 tar -cf 2.tar file.jpg 
$ tar -tf 2.tar 
file.jpg

Information stored as extended attributes:

  • Resource forks (since 10.4)
    • Custom icons set in Finder and the images of Icon\r files
    • Metadata in PSD files
    • Script objects stored in scpt files, AppleScript Editor window state
  • Information about aliases
  • Quarantine status, download URLs
  • Spotlight comments
  • Encoding of files saved with TextEdit
  • Caret position of files saved with TextMate
  • Skim notes

You can see ACLs with ls -le:

$ ls -led /Applications/
drwxrwxr-x@ 146 root  admin  4964 Jun 17 22:53 /Applications/
 0: group:everyone deny delete