Linux centosVMware 压缩打包介绍、gzip压缩工具、bzip2压缩工具、xz压缩工具。
一、压缩打包介绍
Lnux下常见的压缩文件通常是.tar.gz模式,还有.tar、.gz、.bz2、.zip、.tar.bz2、.tar.xz。
.gz:表示由gzip压缩工具压缩的文件
.bz2:表示由gzip2压缩工具压缩的文件
.tar:表示由tar打包程序打包的文件(tar并没有压缩功能,只是把一个目录合并成一个文件)
.tar.gz:表示先由tar打包,然后再由gzip压缩
.tar.bz2:表示由tar打包,再由bzip2压缩
.tar.xz:表示由tar先打包,后再xz压缩
二、gzip压缩工具,不能压缩目录
gzip格式:gzip [-d#] filename,其中#为1-9数字
-d:解压时使用
-#:表示压缩等级,1为最差,9为最好,6为默认
gzip后边直接跟文件名,表示在当前目录下压缩该文件,而原文件也会消失。
[root@davery ~]# cd /tmp/
[root@davery tmp]# ls
0.txt
[root@davery tmp]# mkdir yasuo
[root@davery tmp]# ls yasuo
[root@davery tmp]# ls
0.txt
[root@davery tmp]# du -sh 0.txt
212K 0.txt
[root@davery tmp]# find /etc/ -type f -name "*.conf" -exec cat {} >> 0.txt \;
[root@davery tmp]# du -sh 0.txt
448K 0.txt
[root@davery tmp]# find /etc/ -type f -name "*.conf" -exec cat {} >> 0.txt \;
[root@davery tmp]# du -sh 0.txt
704K 0.txt
[root@davery tmp]# find /etc/ -type f -name "*.conf" -exec cat {} >> 0.txt \;
[root@davery tmp]# du -sh 0.txt
1.2M 0.txt
[root@davery tmp]# find /etc/ -type f -name "*.conf" -exec cat {} >> 0.txt \;
[root@davery tmp]# du -sh 0.txt
1.2M 0.txt
[root@davery tmp]# find /etc/ -type f -name "*.conf" -exec cat {} >> 0.txt \;
[root@davery tmp]# du -sh 0.txt
2.2M 0.txt
[root@davery tmp]# wc -l 0.txt
32388 0.txt
[root@davery tmp]# gzip 0.txt 压缩
[root@davery tmp]# ls
0.txt.gz
[root@davery tmp]# du -sh 0.txt.gz
320K 0.txt.gz
[root@davery tmp]# gzip -d 0.txt.gz 解压
[root@davery tmp]# ls
0.txt
[root@davery tmp]# gzip -1 0.txt 压缩为最低级别
[root@davery tmp]# du -sh 0.txt.gz 查看大小
376K 0.txt.gz
[root@davery tmp]# gzip -d 0.txt.gz
[root@davery tmp]# ls
0.txt
[root@davery tmp]# gzip -9 0.txt 压缩为最高级别
[root@davery tmp]# du -sh 0.txt.gz 查看大小
320K 0.txt.gz
[root@davery tmp]#
[root@davery tmp]# zcat 0.txt.gz 查看压缩内容
扩展
[root@davery tmp]# gzip -d 0.txt.gz
[root@davery tmp]# gzip -c 0.txt > /tmp/0.txt.gz 解压后不会消失
[root@davery tmp]# ls
0.txt.gz
[root@davery tmp]# ls /tmp/0.txt.gz
/tmp/0.txt.gz
[root@davery tmp]# file !$
file /tmp/0.txt.gz
/tmp/0.txt.gz: gzip compressed data, was "0.txt", from Unix, last modified: Tue Apr 3 19:53:32 2018
[root@davery tmp]#
[root@davery tmp]# gzip -d -c /tmp/0.txt.gz > /tmp/yasuo/1.txt
[root@davery tmp]# ls
0.txt
1.txt
[root@davery tmp]# wc -l 0.txt 1.txt
32388 0.txt
20 1.txt
32408 总用量
[root@davery tmp]#
root@davery tmp]# du -sh *.txt
1.3M 0.txt
4.0K 1.txt
[root@davery tmp]#
三、bzip2压缩工具
格式:bzip2 [-dz] filename ,
-z:压缩
-d:解压缩
[root@davery tmp]# yum install -y bzip2 安装
[root@davery tmp]# bzip2 0.txt
[root@davery tmp]# ls
0.txt.bz2
[root@davery tmp]# du -sh 0.txt.bz2
132K 0.txt.bz2
[root@davery tmp]# bzip2 -d 0.txt.bz2
[root@davery tmp]# bzip2 -c 0.txt > /tmp/0.txt.bz2
[root@davery tmp]# du -sh /tmp/0.txt.bz2
132K /tmp/0.txt.bz2
[root@davery tmp]#
[root@davery tmp]# bzip2 -d -c 0.txt.bz2 > 2.txt
[root@davery tmp]# du -sh 2.txt
1.3M 2.txt
[root@davery tmp]# file 0.txt 2.txt 看文件类型
0.txt: C source, UTF-8 Unicode text, with very long lines
2.txt: C source, UTF-8 Unicode text, with very long lines
四、xz压缩工具
格式:xz [-dz] filename
-z 压缩
-d解压
[root@davery ~]# cd /tmp
[root@davery tmp]#
[root@davery tmp]# xz 0.txt
[root@davery tmp]# du -sh 0.txt.xz
48K 0.txt.xz
[root@davery tmp]# xz -d -c 0.txt.xz > 3.txt.xz
[root@davery tmp]# du -sh 3.txt.xz
1.3M 3.txt.xz
[root@davery tmp]#
Linux centosVMware 压缩打包介绍、gzip压缩工具、bzip2压缩工具、xz压缩工具。的更多相关文章
- 压缩打包介绍/gzip压缩工具/bzip2压缩工具/xz压缩工具
6.1 压缩打包介绍 6.2 gzip压缩工具 6.3 bzip2压缩工具 6.4 xz压缩工具 常见的压缩文件格式 windows .rar .zip .7z linux ...
- 压缩打包介绍、gzip、bzip2、xz压缩工具
第5周第1次课(4月16日) 课程内容: 6.1 压缩打包介绍6.2 gzip压缩工具6.3 bzip2压缩工具6.4 xz压缩工具 6.1 压缩打包介绍 为什么要给文件进行压缩呢?首先压缩和不压缩空 ...
- Linux文件压缩/打包/解压
在Linux日常维护中,经常需要备份同步一些比较重要的文件,而在传输过程中如果文件比较大往往会非常慢,而且还会非常占用空间,这时候就需要我们使用压缩工具对大文件进行压缩打包,下面我们来介绍一下常用的压 ...
- linux文件管理--压缩打包
目录 linux文件管理--压缩打包 1.压缩打包介绍 2.gzip压缩工具 3.zip压缩工具 注意: 4.tar压缩工具 5.tar生产案例实践 linux文件管理--压缩打包 1.压缩打包介绍 ...
- 简单了解gzip、bzip2、xz
压缩工具gzip.bzip2.xz分别对应压缩格式.gz..bz2..xz.不过tar命令已经可以满足大部分使用,所以这些格式只简单了解一下.gzip压缩速度最快,xz压缩率最高,bz2适中.一般这三 ...
- 文档压缩 | gzip、bzip2、xz
6.文档的压缩与打包 Linux下常见后缀名所对应的的压缩工具 .gz 表示由gzip压缩工具压缩的文件 .bz2 表示由bzip2压缩工具压缩的文件 .tar 表示由tar打包程序打包的文件(tar ...
- 压缩工具gzip、bzip2、xz的使用
2019独角兽企业重金招聘Python工程师标准>>> 本文使用 为了要压缩 常见压缩格式 压缩工具 gzip压缩工具 bz2压缩工具 xz压缩工具 为什么要压缩 为什么要压缩?文件 ...
- linux 的压缩 打包
1.压缩打包,常见的命令:gzip bzip2 xz zip tar gzip: 不能压缩目录 gip -[0-9] file_name 压缩级别, 默认是6 gzip file_nane ...
- linux 常用压缩打包和解压命令
## zcvf gzip jcvf bzip2 gunzip tar zxvf jxvf
随机推荐
- Debian9安装Metasploit
参考博文:https://www.jianshu.com/p/ea0629b9e367 0x0 添加Kali源 deb http://http.kali.org/kali kali-rolling m ...
- IOS XE-show memory
有些时候,我们可能会遇到IOS XE设备的high memory的情况.我们可以使用的命令去查看相关信息. 例如: Router# show version Router# show memory R ...
- python爬虫(八) requests库之 get请求
requests库比urllib库更加方便,包含了很多功能. 1.在使用之前需要先安装pip,在pycharm中打开: 写入pip install requests命令,即可下载 在github中有关 ...
- 【SSM】AppFileUtils
11 package com.kikyo.sys.utils; import java.io.File; import java.io.IOException; import java.io.Inpu ...
- 【网寻】mui - 点击事件
//本来是需要这样的,结果点击无响应 $(".mui-control-item").on("click",function(event){ alert(1) } ...
- 解决:使用 swiper 自动轮播图片,当拖动过 swiper 内的内容时,导致不继续自动轮播
版本为1.3 当使用了 swiper 后: var mySwiper = new Swiper('.banner .swiper-container', { autoplay: 3000, loop: ...
- php 基础 获取远程连接
1 file_get_contents get $opts = array( 'http'=>array( 'method'=>"GET", 'timeout'=> ...
- 记处理spring-devtools 和 通用mapper 使用问题
问题: tk.mybatis.mapper.MapperException: 无法获取实体类com.*.* 对应的表名 环境: springboot 2.0.6, 通用mapper 2.0.4,还有 ...
- Layui我提交表单时,table.reload(),表格会请求2次,是为什么?
重载两次是因为搜索按钮用的是button 改成<a class="layui-btn" data-type="reload">搜索</a> ...
- 导出EXCEL设置单元格格式
怎么设置导出的EXCEL文件的列格式 如何设置导出的EXCEL文件的列格式在office的EXCEL中我们可以在一个EXCEL文件中,选中一列再点击鼠标右键,选择设置单元格格式,可以将这一列设为文本格 ...