Linux中使用gzip来压缩/解压 *.gz文件
来源:互联网 发布:星际争霸2战役兵种数据 编辑:程序博客网 时间:2024/05/22 01:32
gzip 是linux中常见的压缩/解压工具,最常见的使用对象是*.gz格式的文件,这里简单介绍下它最常见的用法,
GZIP(1) General Commands Manual GZIP(1)
NAME
gzip, gunzip, zcat - compress or expand files
SYNOPSIS
gzip [ -acdfhklLnNrtvV19 ] [--rsyncable] [-S suffix] [ name ... ]
gunzip [ -acfhklLnNrtvV ] [-S suffix] [ name ... ]
zcat [ -fhLV ] [ name ... ]
OPTIONS
-c --stdout --to-stdout 结果写到标准输出,原文件保持不变
-d --decompress --uncompress 解压
-k --keep 压缩或者解压过程中,保留原文件
-r --recursive
-t --test 检查压缩文件的完整性
-v --verbose 显示每个文件的名子和压缩率
-# --fast --best 取值从-1(最快)到-9(最好),默认是-6
示例1,压缩文件
原文件名为file1.txt,压缩后原文件消失,压缩后文件名为file1.txt.gz
root@ubuntu:/tmp# ls -l file1.*
-rw-r--r-- 1 root root 12383865 Aug 21 08:08 file1.txt
root@ubuntu:/tmp# gzip file1.txt
root@ubuntu:/tmp# ls -l file1.*
-rw-r--r-- 1 root root 134416 Aug 21 08:08 file1.txt.gz
示例2,解压文件
root@ubuntu:/tmp# gzip -d file1.txt.gz
root@ubuntu:/tmp# ls -lh file1.*
-rw-r--r-- 1 root root 12M Aug 21 08:08 file1.txt
示例3,压缩的时候,显示压缩率
root@ubuntu:/tmp# gzip -v file1.txt
file1.txt: 98.9% -- replaced with file1.txt.gz
示例4,一条命令压缩多个文件,压缩之后,是各自分开的:
root@ubuntu:/tmp# gzip file1.txt file2.txt
root@ubuntu:/tmp# ls -l
total 1348
-rw-r--r-- 1 root root 134416 Aug 21 08:08 file1.txt.gz
-rw-r--r-- 1 root root 392 Aug 21 08:15 file2.txt.gz
示例5,压缩过程中,保留原文件
root@ubuntu:/tmp# gzip -k file1.txt
root@ubuntu:/tmp# ls file1.*
file1.txt file1.txt.gz
示例6,压缩到标准输出中
可以连接两个文件
root@ubuntu:/tmp# cat file1.txt file2.txt | gzip > foo.gz
或者
root@ubuntu:/tmp# gzip -c file1.txt file2.txt > foo.gz
GZIP(1) General Commands Manual GZIP(1)
NAME
gzip, gunzip, zcat - compress or expand files
SYNOPSIS
gzip [ -acdfhklLnNrtvV19 ] [--rsyncable] [-S suffix] [ name ... ]
gunzip [ -acfhklLnNrtvV ] [-S suffix] [ name ... ]
zcat [ -fhLV ] [ name ... ]
OPTIONS
-c --stdout --to-stdout 结果写到标准输出,原文件保持不变
-d --decompress --uncompress 解压
-k --keep 压缩或者解压过程中,保留原文件
-r --recursive
-t --test 检查压缩文件的完整性
-v --verbose 显示每个文件的名子和压缩率
-# --fast --best 取值从-1(最快)到-9(最好),默认是-6
示例1,压缩文件
原文件名为file1.txt,压缩后原文件消失,压缩后文件名为file1.txt.gz
root@ubuntu:/tmp# ls -l file1.*
-rw-r--r-- 1 root root 12383865 Aug 21 08:08 file1.txt
root@ubuntu:/tmp# gzip file1.txt
root@ubuntu:/tmp# ls -l file1.*
-rw-r--r-- 1 root root 134416 Aug 21 08:08 file1.txt.gz
示例2,解压文件
root@ubuntu:/tmp# gzip -d file1.txt.gz
root@ubuntu:/tmp# ls -lh file1.*
-rw-r--r-- 1 root root 12M Aug 21 08:08 file1.txt
示例3,压缩的时候,显示压缩率
root@ubuntu:/tmp# gzip -v file1.txt
file1.txt: 98.9% -- replaced with file1.txt.gz
示例4,一条命令压缩多个文件,压缩之后,是各自分开的:
root@ubuntu:/tmp# gzip file1.txt file2.txt
root@ubuntu:/tmp# ls -l
total 1348
-rw-r--r-- 1 root root 134416 Aug 21 08:08 file1.txt.gz
-rw-r--r-- 1 root root 392 Aug 21 08:15 file2.txt.gz
示例5,压缩过程中,保留原文件
root@ubuntu:/tmp# gzip -k file1.txt
root@ubuntu:/tmp# ls file1.*
file1.txt file1.txt.gz
示例6,压缩到标准输出中
可以连接两个文件
root@ubuntu:/tmp# cat file1.txt file2.txt | gzip > foo.gz
或者
root@ubuntu:/tmp# gzip -c file1.txt file2.txt > foo.gz
阅读全文
0 0
- Linux中使用gzip来压缩/解压 *.gz文件
- Linux下使用gzip压缩与解压文件
- linux tar.gz 文件压缩,解压
- Linux 下解压.tar.gz文件报错 gzip:stdin:not in gzip format 的解决办法
- GZIP .gz 文件解压与压缩工具类
- linux 解压 压缩 tar.gz
- linux解压 .gz 文件
- linux 解压gz文件
- openresty使用gzip压缩解压
- Linux 文件的解压和压缩 —— gzip命令
- java中zip与gzip实现文件压缩,解压
- Linux解压tar.gz文件时提示gzip:stdin:not错误
- tar gzip biz2 rar unrar的使用,解压tar.gz文件,运行.sh脚本
- 在Linux中使用zip、tar压缩、解压文件
- linux中压缩及解压tar,bz2,gz,tar.bz2,tar.gz
- linux怎样解压.gz文件
- linux 解压cpio.gz文件
- tar.gz文件解压 linux
- 数据包络分析法(DEA)在数学建模中的应用
- canvas标签的用法
- 排列和组合简单的递归思路以及C++实现
- PAT A 1095. Cars on Campus (30)
- vue 绑定单值和双向绑定
- Linux中使用gzip来压缩/解压 *.gz文件
- [第八季]1.Java Web开发概述开发环境及一个简单案例(一)
- win7激活那点事:
- 希尔排序算法
- Hive高级聚合之GROUPING SETS/ROLLUP/CUBE
- Memcached学习总结
- mysql提示密码不符合要求:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
- Arcgis创建多面元素(MultiPolygon)
- 用vs2017编写opencv程序,出现下列错误OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow