Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking how to prevent tar from saving or creating .AppleDouble shadow files and preferably do it in an automated manner. There are a few questions asking why this happens, but I want a solution that helps me prevent this in practice.

What do I need to do using terminal when I tar a directory to prevent these files from being generated?

The duplicate (linked above) as it has been pointed out shows a whole bunch of lines which I do not understand. I'm pretty new to working with Terminal, so that is probably the reason why I don't grasp it.

$ xattr -l file.jpg 0002;50d20c48;Tweetbot;
$ tar -cf 1.tar file.jpg 
$ tar -tf 1.tar 
$ COPYFILE_DISABLE=1 tar -cf 2.tar file.jpg 
$ tar -tf 2.tar 

I just cannot imagine that every time I want to tar a directory I need this bunch only to achieve not getting duplicates.

Regarding the solutions given below in the comments, does it mean that every time I want to tar something I have to use that whole line? Or is there a way to tell the system to set this as the default behaviour when tarring files?

share|improve this question
Set COPYFILE_DISABLE to some value, like COPYFILE_DISABLE=1 tar -cf directory.tar directory. – user495470 Jun 19 '13 at 3:58
Thanks @LauriRanta I saw that question, but did not understand the answer. So what you're saying is that every time I tar a folder, I will have to add the COPYFILE_DISABLE=1 ? Isn't there a way to do that automatically each time I tar files/directories? – Piet Jun 19 '13 at 7:51
I use an alias like alias tarc="COPYFILE_DISABLE=1 tar --exclude '\\.DS_Store' -c". alias tar="COPYFILE_DISABLE=1 tar" would also make tar -x keep ._ files. – user495470 Jun 19 '13 at 20:29
ok got it, thanks! – Piet Jun 20 '13 at 1:05
The other question might ask why but the answer on it does answer how to stop the odd files so the question/answer is a duplicate not the text now says "This question already has an answer here:" – Mark Jun 20 '13 at 1:18
up vote 1 down vote accepted

@LauriRanta answered the question by giving two solutions.

The first solution is to use COPYFILE_DISABLE=1 tar -cf directory.tar directory each time you want to tar a directory without the hidden files.

Her 2nd solution however - and also the one I was looking for - shows how to automate the whole lot by using an alias. If you don't know what an alias is (I didn't) there is a great tutorial available here that shows how to create a temporary alias (only valid for current session) and a permanent alias (stays valid even after turning your Mac off).

I used Lauri's suggestion with a few additions to create a permanent alias:

alias tarc="COPYFILE_DISABLE=1 tar --exclude '\\.DS_Store' -zcf"

so next time I want to tar a directory without overhead I only have to write tarc chosen-gzipped-tar-filename.tgz name-of-directory-i-want-to-tar/ and beam it up to my webhost.

Thanks for all comments and input!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.