2013-02-28

How to avoid Mac temporary files in archives

> tar --exclude "._*" -zcvf template.tgz template
template/
template/.classpath
template/.project
template/build.xml
template/src/
template/src/log4j.properties
template/src/main/
template/src/main/dml/
template/src/main/dml/domain.dml
template/src/main/java/

(VS)

> tar -zcvf template.old.tgz template
template/
template/._.classpath
template/.classpath
template/._.project
template/.project
template/._build.xml
template/build.xml
template/._src
template/src/
template/src/._log4j.properties
template/src/log4j.properties
template/src/._main
template/src/main/
template/src/main/._dml
template/src/main/dml/
template/src/main/dml/._domain.dml
template/src/main/dml/domain.dml
template/src/main/._java
template/src/main/java/

You can also add the following to /etc/profile :
# disable special creation/extraction of ._* files by tar, etc. on Mac OS X
echo "[/etc/profile] disable special creation of ._* files"
COPYFILE_DISABLE=1; 
export COPYFILE_DISABLE

Mac-specific option:
# from man bsdtar
--disable-copyfile
Mac OS X specific.  Disable the use of copyfile(3).

Credits:

Joana

Sources:

http://stackoverflow.com/questions/8766730/tar-command-in-mac-os-x-adding-hidden-files-why

http://superuser.com/questions/61185/why-do-i-get-files-like-foo-in-my-tarball-on-os-x

http://superuser.com/questions/198569/compressing-folders-on-a-mac-without-the-ds-store

No comments: