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.logextension*: 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 command line to create a tar file?
- How do I use the tar command line in Windows 10?
- How do I use the Unix tar zip command?
- How do I compress a file using gzip and tar.xz?
- How do I use the command line 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 zip a file?
- How can I use the CLI to yield a tar file?
- How do I use the Unix tar xzvf command?
- How do I use the Unix tar xvf command to extract files?
See more codes...