Linux/Unix下使用tar命令压缩和解压[tar Examples]

压缩

tar   -czvf   xxx.tar.gz   yourdirectory

解压

解压tar gz(Gzip)文件

tar -xzvf mystuff.tgz


解压普通的tar文件
tar -xvf mystuff.tar

参数的意义

c Create a new archive.
t List the contents of an archive.
x Extract the contents of an archive.
f The archive file name is given on the command line (required whenever the tar output is going to a file)
M The archive can span multiple floppies.
v Print verbose output (list file names as they are processed).
u Add files to the archive if they are newer than the copy in the tar file.
z Compress or decompress files automatically.


tar,tar.gz/tgz

特别要注意的是,".tar"文件不是一个压缩过后的文件,它只是把所有文件集中在了一个文件里,这个文件时没有进行压缩过。而".tar.gz"或者".tgz"文件是被压缩过的。

如果你想对你的tar文件,进行压缩,那么你需要再运行gzip命令。所以如果你想直接压缩,最好在执行tar命令的时候,就加上"z"选项,这样就可以省去gzip这一步。

从文件大小也能看出来.tar和.tar.gz的区别,我的一个目录下有很多源文件,不做任何处理前目录文件的大小为88M,tar命令执行后.tar文件的大小是80M,再gzip之后的大小是9.9M,可以看出.tar文件基本是未经压缩的文件,只有gzip后,文件才会被压缩。


另外需要注意的是,linux/unix中没有untar这个命令

====EOF====

转载请注明出处:http://blog.csdn.net/pan_tian/article/details/7686408


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值