【Linux】文件的压缩和解压——gzip、bzip2、tar
来源:互联网 发布:文档大师 让去淘宝买 编辑:程序博客网 时间:2024/06/05 16:48
文件压缩和解压——gzip
现在test目录下有一个文件test_txt和一个目录tar-test,tar-test目录下也有一个文件,使用gzip对文件test_txt进行压缩和解压。
[lx@localhost test]$ ls tar-test test_txt[lx@localhost test]$ ls ./tar-test/ test_txt[lx@localhost test]$ gzip test_txt [lx@localhost test]$ ls tar-test test_txt.gz[lx@localhost test]$ gzip tar-test/ gzip: tar-test/ is a directory -- ignored //gzip只能对文件进行压缩[lx@localhost test]$ gzip -d test_txt.gz [lx@localhost test]$ ls tar-test test_txt
另一种压缩比更高的压缩命令——bzip2
和gzip操作几乎一样,只是压缩方式不同,注意后缀。
[lx@localhost test]$ ls tar-test test_txt[lx@localhost test]$ bzip2 test_txt [lx@localhost test]$ ls tar-test test_txt.bz2[lx@localhost test]$ bzip2 -d test_txt.bz2 [lx@localhost test]$ ls tar-test test_txt
以上两种压缩命令都能对单个文件操作,tar则可以将文件打包,也可以加入压缩功能。
打包压缩和解压——tar
格式:
对于压缩:tar [参数] 目标目标文件名 要压缩的目录
对于解压:tar [参数] 要解压的文件名 要解压到哪
参数:
-c:打包文件
-x:解开包
–delete:从包中删除文件
-r:追加文件到包中
-t:列出打包文件的内容-C:指定解压、压缩路径
-f:指定打包后的文件名
-j:使用bzip2格式压缩或解压
-z:使用gzip格式压缩或解压
–remove-file:打包后删除源文件
例子:
将./tar-test/目录打包并以gzip格式压缩,命名为tar-test.tar.gz,命名可以随意,但是加上后缀可以让人一目了然
[lx@localhost test]$ tar -czf tar-test.tar.gz ./tar-test/[lx@localhost test]$ ls tar-test.tar.gz tar-test test_txt
将tar-test.tar.gz解压到./tar-test/目录:
lx@localhost test]$ tar -xzf tar-test.tar.gz -C ./tar-test/[lx@localhost test]$ ls ./tar-test tar-test test_txt
阅读全文
0 0
- 【Linux】文件的压缩和解压——gzip、bzip2、tar
- Linux学习记录—文件压缩和打包(gzip,bzip2,tar)
- Linux 压缩 解压命令 tar, gzip, zcat,bzip2, bzcat,compres
- tar的常用方法(压缩/解压/gzip/bzip2)
- Linux精讲——打包和压缩tar、gzip、bzip2、xz、zip
- Linux 文件的解压和压缩 —— gzip命令
- linux tar gzip bzip2 unzip jar 打包和压缩专题
- 文件与文件系统的压缩与打包 tar gzip bzip2
- linux下的打包压缩命令tar、gzip、bzip2
- Linux下的压缩之tar,zip,gzip,bzip2
- gzip,bzip2, xz , zip ,unzip ,解压,压缩;tar打包,解压。
- linux下的文件压缩与打包,compress,gzip,zcat,bzip2,bzcat,tar,find,tarfile,tarball
- linux下的文件压缩与打包---compress,gzip,zcat,bzip2,bzcat,tar,find,tarfile,tarball
- linux下的文件压缩与打包,compress,gzip,zcat,bzip2,bzcat,tar,find,tarfile,tarball
- Linux系统文件的网络传输、打包tar、压缩zip、gzip、bzip2、xz、gz、bz2
- Linux--打包&压缩 tar,gzip,bzip2
- linux基础--压缩指令gzip, bzip2, tar
- Linux 压缩命令 zip tar gzip bzip2
- spring mvc controller返回值的类型
- 比较好的链接
- kafka 集群--3个broker 3个zookeeper创建实战
- writev
- caffe在Ubuntu16环境下CPU版本配置
- 【Linux】文件的压缩和解压——gzip、bzip2、tar
- 通过spring aop去反射目标类方法参数的注解值
- 网络基础
- HDU_【2017 Multi-University Training Contest 1】——1002.Balala Power!
- ajax url路径相对路径和绝对路径问题
- C++图像分类、检测工程
- php 做分页ajax页面不刷新
- 【小技巧】程序运行结束后弹窗提醒
- 根据下拉展示不同的表格内容