4

i'm using GnuWin32's bsdtar, to extract it's simple:

bsdtar  xvf c:\test.zip -C  c:\temp\

but i failed to create zip files. I tried

bsdtar -cf test.zip a.csv b.csv

but the generated file couldn't be opened by winzip.

what's the correct way to generate zip file in command line?

athos
  • 2,371

2 Answers2

4

From https://www.freebsd.org/cgi/man.cgi?query=bsdtar&sektion=1:

-a, --auto-compress
     (c mode only) Use the archive suffix to decide a set of the for-
     mat and the compressions.

So, you would have to use:

bsdtar -a -cf test.zip a.csv b.csv

Which, in fact, is exactly the example they give:

tar -a -cf archive.zip source.c source.h
     creates a new archive with zip format

Pro tip: everytime you are looking for how to do something with a command that comes from the *NIX world, try typing man <command> in Google. This technique never failed me.

0

Simplest:

tar --format zip -cf archive.zip file1 file2
Colonel Panic
  • 12,549