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?
COPYFILE_DISABLE=1 tar -cf directory.tar directory
.alias tarc="COPYFILE_DISABLE=1 tar --exclude '\\.DS_Store' -c"
.alias tar="COPYFILE_DISABLE=1 tar"
would also maketar -x
keep ._ files.