Hack 45. Advanced compression using zip command.
by Ramesh
There are 10 levels of compression provided by zip command.
- Level 0 is the lowest level, where it just archives the file without any compression.
- Level 1 will perform little compression. But, will be very fast.
- Level 6 is the default level of compression.
- Level 9 is the maximum compression. This will be slower when compared to default level. In my opinion, unless you are compressing a huge file, you should always use level 9.
In the example below, I used Level 0, default Level 6, and Level 9 compression on a same directory. See the compressed file size yourself.
- # zip var-log-files-default.zip /var/log/*
- # zip -0 var-log-files-0.zip /var/log/*
- # zip -9 var-log-files-9.zip /var/log/*
- # ls -ltr
- -rw-r--r-- 1 root root 2817248 Jan 1 13:05 var-log-files-default.zip
- -rw-r--r-- 1 root root 41415301 Jan 1 13:05 var-log-files-0.zip
- -rw-r--r-- 1 root root 2582610 Jan 1 13:06 var-log-files-9.zip
当前内容版权归 Ramesh Natarajan 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 Ramesh Natarajan .