Extra files (._ dot underscore) in tar archives

I noticed recently that when I made a tarball of a directory, a lot of extra files were being added that weren’t in the original directory. Apparently the mac version of tar does this to allow it to export all of the detailed file attributes to other operating systems, though it’s not clear why anyone would need this. For example, if you had a directory, stuff, that contained some files

ls stuff
file1.dat     file2.dat

creating a tarball of that directory would produce something like

tar cvfz stuff.tar.gz stuff/
a stuff/._file1.dat
a stuff/file1.dat
a stuff/._file2.dat
a stuff/file2.dat

This blog post explains how to get rid of those extra files by replacing the mac tar with the original tar using MacPorts:

sudo port install gnutar
sudo mv /usr/bin/tar /usr/bin/osxtar
sudo ln /opt/local/bin/gnutar /usr/bin/tar
Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Extra files (._ dot underscore) in tar archives

  1. Pingback: Switch from MacPorts to HomeBrew « OS X Astro Tricks

  2. David G says:

    This seems like massive overkill. Simply executing “export COPYFILE_DISABLE=true” will stop tar from making the ._files

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s