It's a product of extended file attributes. The file foo has an extended attribute, which you can see with ls -l:
$ ls -l
...
-rw-r--r--@ 1 beder staff 760 Oct 26 19:12 foo
The @ sign indicates that it has an extended attribute. To see what it is:
$ xattr 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:
$ xattr -d "com.apple.TextEncoding" foo
$ ls -l
...
-rw-r--r-- 1 beder staff 760 Oct 26 19: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 "Entering $1"
for d in *
do
if [ -d "$d" ]; then
(rmvattr "$d")
else
enc=`xattr $d`
if [$enc != ""]; then
xattr -d $enc $d
fi
fi
done
}
(rmvattr $dir)
Unfortunately, there is no option for tar to ignore extended attributes (on Linux, it appears --no-xattrs works, but this doesn't exist on my version of tar). One option is to copy everything, and use the option cp -X, which ignores extended attributes. Another option, which I found from a couple threads, including here is to set
export COPY_EXTENDED_ATTRIBUTES_DISABLE=true
on Tiger, or
export COPYFILE_DISABLE=true
on Leopard. Then tar (and I think everything else) will ignore all extended attributes.