Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tar command in mac os x adding "hidden" files, why? [closed]

I am writing my own tar archiver. All works fine inside my app (even reading tars generated with other tools) however I cannot get my tar files to work with 3rd party tar file readers. So I tried building a tar file on the command line, building one with my code and binary comparing the two.

But there seems to be an issue:

I have a textfile called Test.txt which I want to add to my tar, so I run the following command in the terminal:

tar -c -f x.tar Test.txt 

When doing this:

tar -tf x.tar 

I get the following list:

./._Test.txt Test.txt 

This is in the Terminal on Mac OS X Lion.

Where does that ./._Test.txt file come from? I don't see it when doing an ls -a

Upon inspecting the tar contents it seems to be some binary data, but I have no idea where it comes from.

like image 846
Joris Mans Avatar asked Jan 07 '12 02:01

Joris Mans


People also ask

Does tar add hidden files?

When you create a tar archive of a directory tree the hidden files are normally not included.

How do I fix hidden files on my Mac?

In Finder, open up your Macintosh HD folder. Press Command+Shift+Dot. Your hidden files will become visible. Repeat step 2 to hide them again!

Do tar files work on Mac?

Create a compressed tar archiveIn the Terminal app on your Mac, enter the tar command, then press Return. The z flag indicates that the archive is being compressed, as well as being combined into one file.


Video Answer


1 Answers

You can add the following to your bashrc file -

export COPYFILE_DISABLE=true 

Or, you can add this option to your tar command at the extraction time

tar -xzpvf x.tar --exclude="._*" 
like image 130
jaypal singh Avatar answered Oct 03 '22 23:10

jaypal singh