prevent doubleapple files creation when tarring directories (Snow Leopard) 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
com.apple.quarantine: 0002;50d20c48;Tweetbot;
$ tar -cf 1.tar file.jpg 
$ tar -tf 1.tar 
./._file.jpg
file.jpg
$ COPYFILE_DISABLE=1 tar -cf 2.tar file.jpg 
$ tar -tf 2.tar 
file.jpg


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?
@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!