compress directory tree in UNIX

2006-11-30 3:33 pm
Which commmand use to archive and compress the directory trees in UNIX ?

回答 (1)

2006-11-30 6:00 pm
✔ 最佳答案
Commone Unix way is use Tar to archive and Compress to compress the data. If you found some file with extension *.tar.z, they are file archived with tar and then compressed with Compress.

While the algorthm of Compress are not free, people mostly use GNU Zip (gzip) or BZip2 (bzip2) for compression. Many sites provide compiled executable gzip/bzip2 for common Unix.The command line is:

tar cf - directories | gzip -c - >file.tar.gz

You see, the extension *.tar.gz indicated it is archived with tar and compressed with GNU Zip. |To extract all the tarball , we use:

gzip -dc file.tar.gz | tar xf -

GNU Tar will help you call GNUZip or BZip2 automatically if you issue the "z" or "j" option:

tar zxf file.tar.gz
tar jxf file.tar.bz2

But you still need GNUZip and BZip2 installed in your Unix system.

Sure, you may found zip, unzip, rar to compress and archived file with one step to *.zip or *.rar but they are not common ammong UNIX people except jar and OpenOffice document (both files are *.zip indeed but with different extension only)


收錄日期: 2021-04-13 13:38:36
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061130000051KK00509

檢視 Wayback Machine 備份