It's a product of extended file attributes. The file foo
has anOS X's tar uses the AppleDouble format to store extended attribute, which you can see with ls -l
:attributes and ACLs.
$ ls -l
...
-rw-r--r--@ 1 beder staff touch file1 file2 file3
$ 760xattr Oct-w 26key 19:12value foofile1
The @
sign indicates that it has an extended attribute. To see what it is:
$ xattrchmod foo
com.apple.TextEncoding
tar
recognizes the extended attribute and creates ._foo
in the archive, which is then reconstructed when it's unpacked. So how to get rid of them? It's actually pretty annoying. For one file, it's easy:
$+a xattr'admin -dallow "com.apple.TextEncoding"delete' foofile2
$ ls -l
...le@ *
-rw-r--r-- @ 1 bederlauri staff 7600 OctMay 2625 1907:12 foo
Presto! But for many files, it's more difficult. I used the following script to get rid of them, but it's pretty slow:
# /usr/bin/bash
dir=$1
rmvattr() {
cd "$1"
echo "Entering09 $1"file1
for d in *
key do5
if [ -d "$d" ]; then
rw-r--r--+ (rmvattr1 "$d")
lauri staff 0 May 25 07:09 elsefile2
0: group:admin enc=`xattrallow $d`delete
-rw-r--r-- 1 lauri staff if0 [$encMay !=25 ""];07:09 thenfile3
$ xattrtar -dcf $enc1.tar $d*
$ tar -tf fi1.tar
fi./._file1
donefile1
}./._file2
file2
(rmvattr $dir)file3
Unfortunately, there is no option for tar
OS X's tar also knows how to ignore extended attributes (on Linux, it appears --no-xattrs
works, but this doesn't exist on my version ofconvert the tar
). One option is_ members back to copy everythingnative formats, and usebut the option cp -X
, which ignores extended attributes. Another option, which I found from a couple threads, including here is_ files are usually kept when archives are extracted on other platforms. You can tell tar to setnot include the metadata by setting COPYFILE_DISABLE to some value:
export$ COPY_EXTENDED_ATTRIBUTES_DISABLE=trueCOPYFILE_DISABLE=1 tar -cf 2.tar file*
on Tiger, or
export$ COPYFILE_DISABLE=truetar -tf 2.tar
file1
file2
file3
- The copyfile functions are described in
man copyfile
ls -l@
shows the keys and sizes of extended attributes,ls -le
prints ACLsxattr -l
lists the keys and values of extended attributesxattr -c
clears all extended attributes (-d can't be used alone)chmod -N
deletes ACLs- Zip files created on OS X use a __MACOSX folder to store similar metadata
on Leopard and newer OS X. Then tar
(and I think everything else) will ignore allInformation stored as extended attributes.:
- Resource forks (resource forks have been extended attributes since 10.4)
- Custom icons set in Finder and the images of Icon\r files
- Metadata in PSD files
- Objects stored in scpt files, AppleScript Editor window state, descriptions of scripts
- Information about aliases (aliases stop working if extended attributes are removed)
- Quarantine status or source URLs of files downloaded from the internet
- Spotlight comments
- Encoding of files saved with TextEdit
- Caret position of files opened with TextMate
- Skim notes