0

This question already has an answer here:

How to compress a file into zip format without having zip package installed? Pretty much what I need to do. I tried tar -czf loremipsum.zip but the format isn't a correct zip format when I try to uncompress it on windows. I'm limited and won't be able to install the package. Is there any work around?

marked as duplicate by slm Jul 21 '18 at 3:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What operating system and version are you running? – Mark Plotnick Jul 20 '18 at 17:47
3

A number of tools can create zip files, perhaps one of them will be available...

7-Zip can be used as follows:

7z a yourzip.zip files ...

Java’s JAR can also be used, as follows:

jar cMf yourzip.zip files ...

(the M option tells jar not to create a manifest).

You could also download zip and run that instead of relying on a copy installed on the system, it has hardly any dependencies:

wget ftp://ftp.info-zip.org/pub/infozip/unix/linux/unz551x-glibc.tgz ftp://ftp.info-zip.org/pub/infozip/unix/linux/zip23x-glibc.zip
tar xf unz551x-glibc.tgz unzip-5.51/unzip
unzip-5.51/unzip zip23x-glibc.zip zip

This will extract a zip binary which you can then use to create your zip file.

0

tar doesn't know how to handle PKZIP files. If you want to use tar, your options are "gzip" (z), "bzip2" (j), and "compress" (Z).

  • 1
    ... and xz (J), and lzip (--lzip), and lzma (--lzma), and lzop (--lzop) ;-). – Stephen Kitt Jul 20 '18 at 15:18
  • Depends on your build of tar. – DopeGhoti Jul 20 '18 at 16:17
  • 1
    Of course. But the latest, J, was given its current meaning in 2009... – Stephen Kitt Jul 20 '18 at 16:25
  • It does not appear on the manual page for the implementation of tar in MacOS 10.13, dated 12-10-2009. – DopeGhoti Jul 20 '18 at 17:18
  • Ah yes, sorry, I didn’t think BSD tar even supported j, which was rather presumptive on my part. My comment only applies to GNU tar. – Stephen Kitt Jul 20 '18 at 18:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.