Guig
Guig

Reputation: 10387

compress list of files and directories with brotli

I'd like to use brotli to compress a list of files and directories. I'm able to do this with zip running

zip -r  archive.zip *

and I'm looking for a similar command with brotli. I've tried

tar -cf archive.gz * && \
brotli -n -q 11 -o archive.zip archive.gz

but after decompression the zip doesn't have the same structure than with zip.

Upvotes: 7

Views: 6682

Answers (4)

ehiller
ehiller

Reputation: 1557

Either of these commands will work to create a brotli compressed tar file without an intermediate tar file:

  1. Directly using tar with the option --use-compress-program
    tar -cvf test-output.tar.br --use-compress-program="brotli -Z" ./my_data_to_compress
    
  2. Piping to brotli
    tar --create --verbose ./my_data_to_compress | brotli --output=compressed_files.tar.br
    

Upvotes: 2

Alix Axel
Alix Axel

Reputation: 154623

Your second command is actually right. Brotli, like Gzip/Bzip2/etc can only compress a single file.

What you must do is first package all of your files in a tarball:

tar -cvf output.tar /path/to/dir

And then compress the resulting tarball with Brotli:

brotli -j -Z output.tar

Which should leave you with a output.tar.br file (similar to *.tar.gz gzipped tarballs).

Upvotes: 10

Mateus Velleda Vellar
Mateus Velleda Vellar

Reputation: 97

you can try creating a .tar file instead of .gz

Upvotes: -1

alchemist95
alchemist95

Reputation: 804

Have you tried Brotli-cli?

This comes with a lot of options to get files compressed using Brotli

Upvotes: 0

Related Questions