compress directory tree in UNIX

Which commmand use to archive and compress the directory trees in UNIX ?

1 個解答

評分
  • ?
    Lv 4
    1 十年前
    最愛解答

    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)

還有問題嗎?立即提問即可得到解答。