Saturday, November 3, 2012

compress and decompress

tar options

-c, --create         create a new archive  
-t, --list           list the contents of an archive
-u, --update         only append files newer than copy in archive
-x, --extract        extract files from an archive
-a, --auto-compress  use archive suffix to determine the compression program
-f, --file ARCHIVE   use archive file or device ARCHIVE
-v, --verbose        verbosely list files processed  

compress options
-j, --bzip2
-z, --gzip, --gunzip --ungzip
-J, --xz
--lzma 
-Z, --compress, --uncompress


簡言之,常用的格式

create    [zj]cvf Dir.xxx Dir
extract   [zj]xvf Dir.xxx

懶的想的話 a 選項可以打天下 acf or axf 萬用


================================================


tar
$ tar cvf FileName.tar DirName
$ tar xvf FileName.tar


gz
$ gzip FileName
$ gunzip FileName.gz      # or gzip -d

tar.gz
$ tar zcvf FileName.tar.gz DirName
$ tar zxvf FileName.tar.gz


bz2
$ bzip2 FileName          # or bzip2 -z
$ bunzip2 FileName.bz2    # or bzip2 -d

tar.bz2
$ tar jcvf FileName.tar.bz2 DirName
$ tar jxvf FileName.tar.bz2


tgz (其實就是 gzip)
$ tar zcvf FileName.tgz DirName
$ tar zxvf FileName.tgz

tar.tgz
$ tar zcvf FileName.tar.tgz FileName
$ tar zxvf FileName.tar.tgz



.7z   
Arch pacman:  extra/p7zip
$ 7zr a FileName
$ 7zr x FileName.7z


xz
xz FileName
xz -d FileName


lzma   # XZ 的一種 format
lzma FileName
lzma -z



lha    # 這個很少見,比較有梗的大概是他的 man page 的 BUS 吧(?)

$ lha a FileName.lha FileName
$ lha x FileName.lha




Z (compress)

這個超級古老了,應該不會遇到 (大多已被 gzip 取代)
compress 原本是 UNIX 下的商業軟體,其 POSIX 實現是 ncompress
$ compress FileName
$ uncompress FileName.Z

tar.Z

$ tar Zcvf FileName.tar.Z DirName
$ tar Zxvf FileName.tar.Z






.zip   # we love gzip!
$ zip FileName.zip DirName
$ unzip FileName.zip



.rar
$ rar a FileName.rar DirName
$ rar x FileName.rar
$ unrar x FileName.rar



No comments:

Post a Comment