.bz2与.gz文件的区别

.bz2和.gz都是linux下压缩文件的格式,有点类似windows下的.zip和.rar文件。

.bz2和.gz的区别在于,前者比后者压缩率更高,后者比前者花费更少的时间。也就是说同一个文件,压缩后,.bz2文件比.gz文件更小,但是.bz2文件的小是以花费更多的时间为代价的。

压缩实例:对一个599M的文件夹workspace进行压缩

bz2文件

time tar -jcvf j.tar.bz2 workspace/

340M 56.8%

real 13m20.975s

user 11m13.872s

sys 0m5.985s

gz文件

time tar -zcvf z.tar.gz workspace/

348M 58.1%

real 2m10.305s

user 0m54.228s

sys 0m7.399s

总结:压缩后,.bz2文件只比.gz文件小了8M,但却花费了后者6倍多的时间。当然,压缩的比率,时间跟被压缩文件的格式,大小等因素有关。所以,本例不能说明使用gz比使用bz2更划算,但至少可以证明bz2比gz压缩率更高,gz比bz2花费更少的时间。
原文地址:http://www.linuxeden.com/html/newbie/20080417/55920.html

发表新评论

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <i> <b> <a> <em> <strong> <small> <big> <cite> <code> <img> <ul> <ol> <li> <dl> <dt> <dd> <tbody> <th> <table> <caption> <colgroup> <col> <thead> <tfoot> <br> <tr> <table> <td> <span> <p> <h1> <h1> <h1> <h2> <h3> <h4> <h5> <hr> <!--> <ins> <del> <kbd> <quote> <blockquote>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
5 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.