How to create a Linux compatible zip archive of a directory on a Mac

Related searches

I've tried multiple ways of creating a zip or a tar.gz on the mac using GUI or command lines, and I have tried decompressing on the Linux side and gotten various errors, from things like "File.XML" and "File.xml" both appearing in a directory, to all sorts of others about something being truncated, etc.

Without listing all my experiments on the command line on the Mac and Linux (using tcsh), what should 2 bullet proof commands be to:

1) make a zip file of a directory (with no __MACOSX folders)

2) unzip / untar (whatever) the Mac zip on Linux with no errors (and no __MACOSX folders)

IT staff on the Linux side said they "usually use .gz and use gzip and gunzip commands".

Thanks!

After much research and experimentation, I found this works every time:

1) Create a zipped tar file with this command on the Mac in Terminal:

tar -cvzf your_archive_name.tar.gz your_folder_name/

2) When you FTP the file from one server to another, make sure you do so with binary mode turned on

3) Unzip and untar in two steps in your shell on the Linux box (in this case, tcsh):

gunzip your_archive_name.tar.gz

tar -xvf your_archive_name.tar

zip(1): package/compress files, Mac OS X. Though previous Mac versions had their own zip port, zip supports Mac An entire directory structure can be packed into a zip archive with a single a filter, zip creates a Zip64 archive that requires a PKZIP 4.5 or later compatible � To create a Zip archive of a directory you would use: zip -r archivename.zip directory_name. You can also add multiple files and directories in the same archive: zip -r archivename.zip directory_name1 directory_name2 file1 file1 Compression Methods and Levels # The default compression method of Zip is deflate. If the zip utility determines that a file cannot be compressed it simply stores the file in the archive without compressing it using the store method. In most Linux distributions the

First off, the File.XML and File.xml cannot both appear in an HFS+ file system. It is possible, but very unusual, for someone to format a case-sensitive HFSX file system that would permit that. Can you really create two such files and see them listed separately?

You can use the -X option with zip to prevent resource forks and extended attributes from being saved. You can also throw in a -x .DS_Store to get rid of those files as well.

For tar, precede it with COPYFILE_DISABLE=true or setenv COPYFILE_DISABLE true, depending on your shell. You can also throw in an --exclude=.DS_Store.

Your "IT Staff" gave you a pretty useless answer, since gzip can only compress one file. gzip has to be used in combination with tar to archive a directory.

How can I create a zip archive for Windows and Linux users?, zip -r -x .DS_Store directory.zip directory. zip removes extended attributes and ACLs by default. find directory -name .DS_Store -delete; ditto -ck� Including Directories in ZIP Files. To include sub-directories in the ZIP file, use the -r (recursive) option and include the name of the sub-directory on the command line. To create a ZIP file as before and also include the archive sub-directory, use this command. zip -r -q source_code archive/ *.c *.h.

On my Mac and in ssh bash I use the following simple commands:

Create Zip File (-czf)
tar -czf NAME.tgz FOLDER
Extract Zip File (-xzf)
tar -xzf NAME.tgz

Best, Mike

How to Zip a File in Ubuntu, Ubuntu's zip command can help you assemble and archive your computer files. produce compressed archives that are compatible with Windows zip format you can extract on Linux and non-Linux systems like Windows and Mac OS X. Navigate to the folder containing the file you want to zip using the "cd" command. Select a location for the ZIP file, using your home directory is the easiest. Select type .zip. See man zip for information on how to create a ZIP file in command line.

Creating a ZIP file that extracts cross platform, The Linux is running zip 3.0 (July 5th, 2008) and unzip 6.00 (20 April, 2009). No idea what Windows is using. I need the zip to properly extract on Mac OS X, Linux ,� Select the files, right click and click compress Now you can create a compressed archive file in zip, tar xz or 7z format. In case you are wondering, all these three are various compression algorithms that you can use for compressing your files. Give it the name you desire and click on Create.

How to Zip and Unzip Files and Folders on a Mac, Apple makes zipping and unzipping files and folders extremely easy by in the pop-up menu and the name of the zip file that is created. zip -r archive_name.zip folder_to_compress. To extract. unzip archive_name.zip. If you want to make a zip without those invisible Mac resource files such as “_MACOSX” or “._Filename” and .ds store files, use the “-X” option in the command so: zip -r -X archive_name.zip folder_to_compress TAR.GZ – Cross Platform

Select the items you want to include in the zip file. Shift-click to select a range of files or command-click to select nonadjacent items. After you select all the files and folders you want to include in the zip file, right-click or Control-click on any one of the items and select Compress from the pop-up menu.

Comments
  • Just do tar xvfz ... to extract. The z has tar call gzip for you, and you avoid creating a large, intermediate .tar file.
  • That will not prevent resource fork/extended attribute information from being put in the tar file, which shows up as ._* files. Nor will it prevent .DS_Store files from being archived. See my answer for how to avoid those.
  • It's also not a "zipped" file, at least by the traditional definition of "zipped." A .zip file is compressed with PKZIP or any of the utilities based on the Info-Zip package, including zip/unzip and WinZIP. gzip uses the same compression scheme, but it does not archive. Its use case is to serve as a filter for tar. The more recent additional "zips," including bzip2 (another compressor-only) and 7Zip (archive+compress), only serve to confuse things.
  • On my mac, I had gotten mixed case XML and xml files. For the script, I normalized them by simply renaming them all to lower case. In one of the zip attempts, I forget which one, the archive unzipped on the Linux box with both in there! I do have a working solution after much trial and error. I'll post it below.
  • Linux does allow file names that differ only in case. To get that you would have archive two files in different directories on the Mac whose names differ only in case (since they can't coexist in the same directory), and the unarchive them into the same directory on Linux.
  • Mark, my current statement is "tar -cvzf archive.tar.gz my_folder/". How do I integrate the -x option? I tried and it said I can't have both c and x.
  • You need to read the answer more carefully. -x is for zip. For tar you use --exclude.
  • Thanks, I missed that!