2

Purpose: zip a folder in window and extract it in linux.

I prefer to https://superuser.com/a/898508/1451256 and I realize there is no description for -a option in tar.exe --help: https://ss64.com/nt/tar.html , so I just follow as the tar official: "tar -cvzf xxx" but when I've tried to extract that zip file in linux by "unzip xxx", it throws error " End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. "

So I suspect the zip file is not zipped properly, then I try to add -a option, it works perfectly. As comment from https://superuser.com/a/1473257/1451256 : it says without the -a option "it assumes a plain tar archive", I don't know what it means. Can someone explains what is the -a option? Thanks.

1 Answer 1

2

tar(1):

...
-a, --auto-compress
             (c mode only) Use the archive suffix to decide a set of the
             format and the compressions.  As a simple example,
                   tar -a -cf archive.tgz source.c source.h
             creates a new archive with restricted pax format and gzip
             compression,
                   tar -a -cf archive.tar.bz2.uu source.c source.h
             creates a new archive with restricted pax format and bzip2
             compression and uuencode compression,
                   tar -a -cf archive.zip source.c source.h
             creates a new archive with zip format,
                   tar -a -jcf archive.tgz source.c source.h
             ignores the "-j" option, and creates a new archive with
             restricted pax format and gzip compression,
                   tar -a -jcf archive.xxx source.c source.h
             if it is unknown suffix or no suffix, creates a new archive with
             restricted pax format and bzip2 compression.
...
13
  • Teach the boy to fish Tom! :-) "help" is a built-in command of the Bash Shell, documenting commands for that shell. "man" manual pages are the system-wide doumentation system, traditionally of Unix. "info" is yet another, originating from the GNU project... all 3 overlap, but generally "man" is the most readily accessible/comprehensive. So next time, just use "man tar", and here's the online equivalent of that command... www.gnu.org/software/tar/manual/
    – user1138
    Jun 29, 2021 at 10:34
  • @user1138 Well, I linked tar(1) to the page on man7.org...and yeah if he's on cygwin / msys2 he can probably get man-db or so as well to use man.
    – Tom Yan
    Jun 29, 2021 at 10:42
  • All good "man"! (boom-tish) I'll see myself out now...
    – user1138
    Jun 29, 2021 at 10:47
  • 1
    thanks all for the information, Sorry but I still don't get it, the link tar(1) belongs to linux, right? What I use is tar.exe, are they the same? What is the different of the zip file when using -a option and not using it? Jun 30, 2021 at 14:58
  • Well I have no idea where/how you get it but most likely it's GNU tar anyway (the other popular variant being bsdtar in libarchive). Use --version to find out if you want to.
    – Tom Yan
    Jun 30, 2021 at 15:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .