当前位置:网站首页>zip gzip tar压缩进阶版
zip gzip tar压缩进阶版
2022-07-29 07:01:00 【学习record】
1.gzip与gunzip
gzip压缩文件时,会将源文件压缩并在文件名称后加 ‘.gz’。
gzip
语法:gzip [选项] 文件名
常用选项:
-d 解开压缩文件
-l 列出压缩文件的相关信息
-r 递归处理,将指定的目录下的文件和子目录一起处理
-v 显示压缩执行过程
-n 压缩文件时,不保存原来的文件名及时间戳
-N 压缩文件是,保存原来的文件名及时间戳
-<压缩效率> 压缩效率是介于1-9的数值,预设值为“6”,数值越大,压缩效率越高
举例:
1.将 monkey.txt 文件压缩为 .gz 文件
-rw-r--r--. 1 root root 84 Jul 28 10:04 monkey.txt
[[email protected] home]# gzip monkey.txt
[[email protected] home]# ll
-rw-r--r--. 1 root root 71 Jul 28 10:04 monkey.txt.gz
2.解压monkey.txt.gz,并列出详细信息
[[email protected] home]# gzip -dv monkey.txt.gz
monkey.txt.gz: 50.0% -- replaced with monkey.txt
3.将目录 search 下的所有文件都压缩为 .gz 并显示压缩信息
[[email protected] home]# gzip -rv search/
search//eee: 0.0% -- replaced with search//eee.gz
search//ddd: 0.0% -- replaced with search//ddd.gz
search//1.tar: 98.7% -- replaced with search//1.tar.gz
gzip: search//ikun.tar.gz already has .gz suffix -- unchanged
[[email protected] home]# cd search/
[[email protected] search]# ll
-rw-r--r--. 1 root root 155 Jul 28 15:51 1.tar.gz
-rw-r--r--. 1 root root 24 Jul 28 15:50 ddd.gz
-rw-r--r--. 1 root root 24 Jul 28 15:50 eee.gz
-rw-r--r--. 1 root root 208 Jul 28 16:05 ikun.tar.gz
gunzip
语法:gunzip 文件名.gz
2.zip与unzip
zip包需要安装:yum install zip -y
zip压缩时,不会压缩源文件,因此可以用来备份文件
zip
语法:zip 文件名
常用选项:
-d 从压缩文件内删除指定的文件
-r 递归处理,将指定目录下的所有文件和子目录一起处理
-m 向压缩文件中添加文件
-x 压缩时,排除某个文件
-<压缩效率> 压缩效率介于1-9
举例:
1.压缩 search目录下所有文件,删除其中的 ddd 文件
[[email protected] search]# zip -r dd.zip ./*
adding: ddd (stored 0%)
adding: eee (stored 0%)
adding: wq (stored 0%)
[[email protected] search]# ll
total 4
-rw-r--r--. 1 root root 0 Jul 28 15:50 ddd
-rw-r--r--. 1 root root 422 Jul 28 20:36 dd.zip
-rw-r--r--. 1 root root 0 Jul 28 15:50 eee
-rw-r--r--. 1 root root 0 Jul 28 20:27 wq
[[email protected] search]# zip -d dd.zip ddd
deleting: ddd
2.向压缩包 dd.zip 中加入 cx 文件
[[email protected] search]# zip -m dd.zip cx
adding: cx (stored 0%)
[[email protected] search]# zipnote dd.zip
@ eee
@ (comment above this line)
@ wq
@ (comment above this line)
@ cx
@ (comment above this line)
@ (zip file comment below this line)
3.压缩 search目录下所有文件,排除 ddd文件
[[email protected] search]# zip -r like.zip ./* -x ddd
adding: dd.zip (stored 0%)
adding: eee (stored 0%)
adding: wq (stored 0%)
unzip
unzip包需要安装:yum install unzip
语法:unzip [选项] 包名.zip 解压路径
常用选项:
-d 指定文件或目录解压后要存储的目录
-n 解压时不覆盖原有的文件
-v 查看压缩文件夹目录但不解压
-o 解压时,不询问用户,直接覆盖原有文件
举例:
1.将nums.zip文件解压到/home/csdn/new
[[email protected] csdn]# unzip nums.zip -d /home/csdn/new
Archive: nums.zip
extracting: /home/csdn/new/aaa
extracting: /home/csdn/new/num1
extracting: /home/csdn/new/num2
[[email protected] csdn]# cd new/
[[email protected] new]# ll
total 0
-rw-r--r--. 1 root root 0 Jul 28 21:03 aaa
-rw-r--r--. 1 root root 0 Jul 28 21:03 num1
-rw-r--r--. 1 root root 0 Jul 28 21:03 num2
2.查看压缩文件的内容
[[email protected] csdn]# unzip -v nums.zip
Archive: nums.zip
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
0 Stored 0 0% 07-28-2022 21:03 00000000 aaa
0 Stored 0 0% 07-28-2022 21:03 00000000 num1
0 Stored 0 0% 07-28-2022 21:03 00000000 num2
-------- ------- --- -------
0 0 0% 3 files
3.解压nums.zip 不覆盖原有文件
[[email protected] csdn]# unzip -n nums.zip -d /home
4.解压nums.zip到/home,查看文件 aaa是否被覆盖(看文件时间)
-rw-r--r--. 1 root root 0 Jul 28 21:12 aaa
[[email protected] home]# unzip -o csdn/nums.zip -d /home
Archive: csdn/nums.zip
extracting: /home/aaa
extracting: /home/num1
extracting: /home/num2
[[email protected] home]# ll
-rw-r--r--. 1 root root 0 Jul 28 21:03 aaa
3.bzip2与bunzip2
bzip2
安装bzip2:yum install bzip2
bzip2用于创建和管理“.bz2” 格式的压缩包
常用选项:
-d 执行解压缩
-z 强制执行压缩
-t 测试.bz2压缩文件的完整性
-k bzip2在压缩或解压时,会删除原始文件。若要保留原有文件,可以使用这个参数
-v 显示版本信息
举例:
1.解压 aaa.bz2
[[email protected] csdn]# bzip2 -d aaa.bz2
2.强制压缩文件 num1
[[email protected] csdn]# bzip2 -z num1
3.测试压缩文件num1.bz2的完整性
[[email protected] csdn]# bzip2 -tv num1.bz2
num1.bz2: ok
bunzip
语法:bunzip 压缩包名.bz2
tar压缩
打包与压缩:打包是指讲一大堆文件或目录变成一个总的文件;压缩是将一个大的文件通过算法变成小的文件
选项:
-c 建立压缩档案
-x 解压
-t 查看内容
-r 向压缩文档末尾追加文件
-u 更新原压缩包中的文件
-z 有gzip属性的
-j 有bizp2属性的
-J 有xz属性的
-v 显示所有过程
边栏推荐
- Gin service exit
- Section 7 - compilation of programs (preprocessing operations) + links
- Win11 system error: code execution cannot continue because ierutil.dll cannot be found. Reinstalling the program may fix this problem
- 2022-07-28: what is the output of the following go language code? A:AA; B:AB; C:BA; D:BB。 package main import ( “fmt“ ) func main() { f
- mysql 单表最多能存多少数据?
- logback中RollingFileAppender属性简介说明
- 7-2 计算正五边形的面积和周长 (25分)
- Redis基础篇
- Some learning and understanding of vintage analysis
- Nodejs installation tutorial
猜你喜欢

It's enough for MySQL to have this article (disgusting and crazy typing 37k words, just for Bo Jun's praise!!!)

2-统一返回类DTO对象

Latest 10 billion quantitative private placement list

Nodejs installation tutorial

Interface test actual project 03: execute test cases

如何与斯堪尼亚SCANIA建立EDI连接?

JS 鸡生蛋与蛋生鸡问题,Object与Function究竟谁出现的更早?Function算不算Function的实例?

0 9 布隆过滤器(Bloom Filter)

QT专题:基础部件(按钮类,布局类,输出类,输入类,容器类)

H3C_ Using setting default static routing priority to realize the active and standby function of export dual lines
随机推荐
js中break与continue和return关键字
Personal blog system (with source code)
JS day 4 process control (if statement and switch statement)
JS break and continue and return keywords
OCR光学字符识别方法汇总
MySQL uses the client and select methods to view the summary of blob type fields
MySQL - multi table query
7-2 计算正五边形的面积和周长 (25分)
Scala 高阶(十):Scala中的异常处理
ERROR 1045 (28000) Access denied for user ‘root‘@‘localhost‘解决方法
Win11vmware turns on the virtual machine and restarts on the blue screen and the solution that cannot be started
用户列表 圆形头像并跟随小板块
3-global exception handling
Scala 高阶(九):Scala中的模式匹配
Docker最新超详细教程——Docker创建运行MySQL并挂载
第7节-程序的编译(预处理操作)+链接
Meta configuration item of route
Thinkphp6 realizes database backup
Can I specify memory parameters in SQL statements?
When NPM is installed, it is stuck. There are five solutions