cli-tarHow can I achieve the highest compression when using tar and gzip?
The highest compression when using tar and gzip can be achieved by using the -9 flag. This flag will enable maximum compression, which is the slowest but also the most effective.
Example code
tar -cvzf archive.tar.gz --exclude=*.log * -9
This command will create an archive called archive.tar.gz
and compress all files except for those with the .log
extension using the maximum compression level.
The parts of the command are as follows:
tar
: the command to create the archive-cvzf
: the flags for the command-c
: create an archive-v
: verbose output-z
: compress the archive with gzip-f
: use archive file
archive.tar.gz
: the name of the archive file--exclude=*.log
: exclude all files with the.log
extension*
: the files and directories to archive-9
: the maximum compression level
For more information about tar
command, please refer to the following link:
More of Cli Tar
- How do I use the Unix tar zip command?
- How do I use the shell to tar and zip files?
- How can I use tar commands to zip a file?
- How do I use the command line to tar and distribute files?
- How do I use the Unix tar xvf command to extract files?
- How can I use the CLI tar yarn command to compress files?
- How do I use the tar command on Windows?
- How do I use gzip to compress a tar file on Windows?
- How do I compare Unix tar and zip files?
- How do I create a tar.zip file in Unix?
See more codes...