Is there a way to create a tar file in OS X (Sierra, preferably) that does not include the ._ files? I've tried using the --exclude option, but clearly don't know the right pattern to use.
3 Answers
To suppress the creation of AppleDouble ._
files, use: --disable-copyfile
Example: tar --disable-copyfile -cf file.tar file
-
Wow. How terribly sneaky. Only becomes apparent they're in there when you go to extract. Even a listing with
-t
doesn't show them. And the option is not documented! Where do you discovery such sorcery for yourself? Commented Nov 27, 2020 at 3:50 -
bsdtar 2.8.3 - libarchive 2.8.3 on macOS 10.14.6 doesn't work anymore, sadly. Commented Feb 11, 2021 at 20:20
The accepted answer didn't work on MacOS Monterey (V 12.4). The tar is bsdtar and the man page revealed that there's a separate option to be specified --no-mac-metadata
$ tar -czv --no-mac-metadata -f <file_name> <filelist>
Sequence of the options seem to matter as following command didn't give desired result:
$ tar --no-mac-metadata -czvf <file_name> <filelist>
-
To say that I am extremely disappointed to learn that a system tool has this borderline malicious "extension" enabled by default would be a serious understatement.– cbmanicaCommented Feb 7, 2023 at 22:28
In recent macOS versions --disable-copyfile
option suggested in other answer might do nothing, but tar seems to honor COPYFILE_DISABLE
environment variable. Use it like this:
COPYFILE_DISABLE=1 tar -cf file.tar file
-
1RE: "In recent macOS versions
--disable-copyfile
option suggested in other answer does nothing," -- I find that statement to be false in macOS Catalina. I just tested it and it works! (Doesn't work in macOS Big Sur) Commented Feb 11, 2021 at 20:32 -
@user3439894 well,
--disable-copyfile
doesn't work in Mojave, and I can't test other versions. Weird. Commented Feb 12, 2021 at 0:03 -