0

I have downloaded Cygwin and the package to zip files (bzip2) but I cant figure out how to use its command to simply zip a file to another location.

All I want to do is something like:

bzip2 myfile somelocation
Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
swag antiswag
  • 349
  • 1
  • 4
  • 12

1 Answers1

1

You want to use:

bzip2 --keep [file to zip] > [Destination]

Omit brackets when filling in the details.

So, for your example, you would want to say:

bzip2 --keep myfile > somelocation

bzip2 writes to standard output, so you just need to use basic shell tools to direct or pipe this output to your destination. Your destination will be a file, not a folder, so if you want the compressed file to go inside a folder called somelocation, you would want to say something like

bzip2 --keep myfile > somelocation/myfile.bz2

The --keep parameter tells bzip2 not to delete your original file. If you do want to delete it, omit this parameter.

I tested this with my own installation of Cygwin on Windows 8.1.

Robert Columbia
  • 6,313
  • 15
  • 32
  • 40
  • Thank you! Is there a way to zip it or convert it to a normal .zip file in the end? I was able to zip it it but the type of the zipped file is .bz2 – swag antiswag Jun 15 '16 at 21:50
  • If you need a zip file you need to install the zip and the unzip packages. Bzip2 and zip use different compression algorithms – matzeri Jun 16 '16 at 12:14