Difference between revisions of "Tar hints for Mac OS X users"

From OpenHatch wiki
Jump to navigation Jump to search
imported>Paulproteus
imported>Paulproteus
 
(3 intermediate revisions by the same user not shown)
Line 18: Line 18:
   
 
ls -a
 
ls -a
  +
  +
However, these special files often cannot be seen using "ls -a".
   
 
If you were creating a tarball of your own code to distribute, you should avoid distributing these extraneous files. The simplest way to create a tar file without these files is to ask tar to exclude them when creating the tar file. So if you would have run this command:
 
If you were creating a tarball of your own code to distribute, you should avoid distributing these extraneous files. The simplest way to create a tar file without these files is to ask tar to exclude them when creating the tar file. So if you would have run this command:
Line 27: Line 29:
 
COPYFILE_DISABLE=true tar zcvf myproject-0.1.tar.gz myproject-0.1/
 
COPYFILE_DISABLE=true tar zcvf myproject-0.1.tar.gz myproject-0.1/
   
Because you pass the ''v'' flag to tar, causing it to operate in verbose mode, you can see which files will be added to the resulting tarball.
+
Because you pass the ''v'' flag to tar, causing it to operate in verbose mode, you can see which files will be added to the resulting tarball. You can confirm that the file is created without the extra files by listing its contents with this command:
  +
  +
tar ztvf myproject-0.1.tar.gz
   
 
== References ==
 
== References ==
   
  +
* [http://superuser.com/questions/61185/why-do-i-get-files-like-foo-in-my-tarball-on-os-x SuperUser.com discussion on the problem]
 
* [http://support.apple.com/kb/TA20578 Apple Knowledge Base article explaining resource forks and the Apple Double format]
 
* [http://support.apple.com/kb/TA20578 Apple Knowledge Base article explaining resource forks and the Apple Double format]
 
* [https://openhatch.org/bugs/issue616 OpenHatch bug describing this problem]
 
* [https://openhatch.org/bugs/issue616 OpenHatch bug describing this problem]

Latest revision as of 22:42, 22 December 2011

Special information for using tar on Mac OS X

You've probably found this page because you created a tar file on your Mac machine, and it contained extra files.

Creating a tar file without ._ files

On Mac OS X, sometimes the operating system creates hidden files whose names start with a period and an underscore. For example, if you have these files:

  • Makefile
  • hello.c

Mac OS will sometimes create extra files alongside them in the same directory named:

  • ._Makefile
  • ._hello.c

They are a special file generated by Mac OS. Most hidden files can be seen using this command from a Terminal (the hyphen-a stands for "all"):

ls -a

However, these special files often cannot be seen using "ls -a".

If you were creating a tarball of your own code to distribute, you should avoid distributing these extraneous files. The simplest way to create a tar file without these files is to ask tar to exclude them when creating the tar file. So if you would have run this command:

tar zcvf myproject-0.1.tar.gz myproject-0.1/ 

instead you need to pass a special set of environment variables to tar. So run it as follows:

COPYFILE_DISABLE=true tar zcvf myproject-0.1.tar.gz myproject-0.1/

Because you pass the v flag to tar, causing it to operate in verbose mode, you can see which files will be added to the resulting tarball. You can confirm that the file is created without the extra files by listing its contents with this command:

tar ztvf myproject-0.1.tar.gz

References