每天一个Linux命令(27)gzip命令
zip命令用来压缩文件。gzip是个使用广泛的压缩程序,文件经它压缩过后,其名称后面会多处“.gz”扩展名。
(1)用法:
用法: gzip [选项参数][-s <压缩字尾字符串>] [文件...]
或 gzip [选项参数][-s <压缩字尾字符串>] [目录]
(2)功能:
功能: gzip是个使用广泛的解压缩程序,它用于解开被gzip压缩过的文件,这些压缩文件预设最后的扩展名为".gz"。
事实上gzip就是gzip的硬连接,因此不论是压缩或解压缩,都可通过gzip指令单独完成。
(3)选项参数:
1) -d --decompress --uncompress 解开压缩文件;
2) -v --verbose 显示指令执行过程;
3) -l --list 列出压缩文件的相关信息;
4) -r --recursive 递归处理,将指定目录下的所有文件及子目录一并处理;
5) -A --catenate: 新增文件到已存在的备份文件;
6) -B 设置区块大小
7) -c 把解压后的文件输出到标准输出设备
(4)实例:
1)[root@localhost Dir]# gzip * 压缩当前目录下的所有文件,文件后缀名加上.gz(gzip调用时自动执行压缩或解压缩命令)
[root@localhost Dir]# gzip *
[root@localhost Dir]# ll
总用量
-r-xr-xr-x. sunjimeng root 5月 : head_text.gz
-r-xr-xr-x. root sunjimeng 5月 : less1.gz
-r-xr-xr-x. root sunjimeng 5月 : less2.gz
2)[root@localhost Dir]# gzip -d * 解压当前目录的所有文件
[root@localhost Dir]# gzip * //解压并不能像压缩时那样什么参数都不带,需要带解压命令-d
gzip: head_text.gz already has .gz suffix -- unchanged
gzip: less1.gz already has .gz suffix -- unchanged
gzip: less2.gz already has .gz suffix -- unchanged
[root@localhost Dir]# gzip -d *
[root@localhost Dir]# ll
总用量
-r-xr-xr-x. sunjimeng root 5月 : head_text
-r-xr-xr-x. root sunjimeng 5月 : less1
-r-xr-xr-x. root sunjimeng 5月 : less2
3)[root@localhost Dir]# gzip -v * 显示命令执行时的具体的步骤
[root@localhost Dir]# gzip -v *
head_text: 42.3% -- replaced with head_text.gz
less1: 4.4% -- replaced with less1.gz
less2: 1.8% -- replaced with less2.gz
[root@localhost Dir]# gzip -dv *
head_text.gz: 42.3% -- replaced with head_text
less1.gz: 4.4% -- replaced with less1
less2.gz: 1.8% -- replaced with less2
4)[root@localhost Dir]# gzip -l *
[root@localhost Dir]# gzip -l *
compressed uncompressed ratio uncompressed_name
42.3% head_text
4.4% less1
1.8% less2
30.3% (totals)
[root@localhost Dir]# ll
总用量
-r-xr-xr-x. sunjimeng root 5月 : head_text.gz
-r-xr-xr-x. root sunjimeng 5月 : less1.gz
-r-xr-xr-x. root sunjimeng 5月 : less2.gz
5)[root@localhost findDir]# tar -cvf Dir.tar Dir 先用tar命令打包
[root@localhost findDir]# tar -cvf Dir.tar Dir
Dir/
Dir/head_text.gz
Dir/less1.gz
Dir/less2.gz
[root@localhost findDir]# ll
总用量
dr-xr-xr-x. root sunjimeng 5月 : Dir
-rw-r--r--. root root 5月 : Dir.tar
[root@localhost findDir]# gzip -v Dir.tar
Dir.tar: 92.1% -- replaced with Dir.tar.gz
[root@localhost findDir]# gzip -l Dir.tar.gz
compressed uncompressed ratio uncompressed_name
92.1% Dir.tar
5)[root@localhost findDir]# tar cvf Dir1.tar -R Dir 打包的几种方法
[root@localhost findDir]# tar cvf Dir1.tar -R Dir
块 :Dir/
块 :Dir/head_text.gz
块 :Dir/less1.gz
块 :Dir/less2.gz
[root@localhost findDir]# tar -cvf Dir2.tar Dir
Dir/
Dir/head_text.gz
Dir/less1.gz
Dir/less2.gz
[root@localhost findDir]# tar -cvf Dir3.tar -R Dir
块 :Dir/
块 :Dir/head_text.gz
块 :Dir/less1.gz
块 :Dir/less2.gz
6)[root@localhost Documents]# gzip -vr findDir 递归的压缩子文件夹下的文件
[root@localhost Documents]# gzip -vr findDir
gzip: findDir/Dir/head_text.gz already has .gz suffix -- unchanged
gzip: findDir/Dir/less1.gz already has .gz suffix -- unchanged
gzip: findDir/Dir/less2.gz already has .gz suffix -- unchanged
gzip: findDir/Dir.tar.gz already has .gz suffix -- unchanged
findDir/Dir1.tar: 92.1% -- replaced with findDir/Dir1.tar.gz
findDir/Dir2.tar: 92.1% -- replaced with findDir/Dir2.tar.gz
findDir/Dir3.tar: 92.1% -- replaced with findDir/Dir3.tar.gz
[root@localhost Documents]# ls -l findDir
总用量
-rw-r--r--. root root 5月 : Dir.tar.gz
-rw-r--r--. root root 5月 : Dir3.tar.gz
-rw-r--r--. root root 5月 : Dir2.tar.gz
-rw-r--r--. root root 5月 : Dir1.tar.gz
dr-xr-xr-x. root sunjimeng 5月 : Dir
[root@localhost Documents]# ls -l findDir/Dir
总用量
-r-xr-xr-x. root sunjimeng 5月 : less2.gz
-r-xr-xr-x. root sunjimeng 5月 : less1.gz
-r-xr-xr-x. sunjimeng root 5月 : head_text.gz
7)[root@localhost findDir]# gzip -rdv Dir 递归的解压目录下的所有.gz的文件
[root@localhost findDir]# ls -l Dir
总用量
-r-xr-xr-x. sunjimeng root 5月 : head_text.gz
-r-xr-xr-x. root sunjimeng 5月 : less1.gz
-r-xr-xr-x. root sunjimeng 5月 : less2.gz
[root@localhost findDir]# gzip -rdv Dir
Dir/head_text.gz: 42.3% -- replaced with Dir/head_text
Dir/less1.gz: 4.4% -- replaced with Dir/less1
Dir/less2.gz: 1.8% -- replaced with Dir/less2
[root@localhost findDir]# ls -l Dir
总用量
-r-xr-xr-x. sunjimeng root 5月 : head_text
-r-xr-xr-x. root sunjimeng 5月 : less1
-r-xr-xr-x. root sunjimeng 5月 : less2
[root@localhost findDir]# gzip -r Dir
[root@localhost findDir]# ls -l Dir
总用量
-r-xr-xr-x. sunjimeng root 5月 : head_text.gz
-r-xr-xr-x. root sunjimeng 5月 : less1.gz
-r-xr-xr-x. root sunjimeng 5月 : less2.gz
[root@localhost findDir]# gzip -dv Dir
gzip: Dir is a directory -- ignored
8)[root@localhost Dir]# gzip --help
[root@localhost Dir]# gzip --help
Usage: gzip [OPTION]... [FILE]...
Compress or uncompress FILEs (by default, compress FILES in-place). Mandatory arguments to long options are mandatory for short options too. -c, --stdout write on standard output, keep original files unchanged
-d, --decompress decompress
-f, --force force overwrite of output file and compress links
-h, --help give this help
-l, --list list compressed file contents
-L, --license display software license
-n, --no-name do not save or restore the original name and time stamp
-N, --name save or restore the original name and time stamp
-q, --quiet suppress all warnings
-r, --recursive operate recursively on directories
-S, --suffix=SUF use suffix SUF on compressed files
-t, --test test compressed file integrity
-v, --verbose verbose mode
-V, --version display version number
-, --fast compress faster
-, --best compress better
--rsyncable Make rsync-friendly archive With no FILE, or when FILE is -, read standard input. Report bugs to <bug-gzip@gnu.org>.
每天一个Linux命令(27)gzip命令的更多相关文章
- 每天一个linux命令(28)--gzip命令
减少文件大小有两个明显的好处,一是可以减少存储空间,二是通过网络传输文件时,可以减少传输的时间.gzip 是在Linux 系统中经常使用的一个对文件进行压缩和解压缩的命令,既方便又好用.gzip 不仅 ...
- linux常用命令:gzip 命令
减 少文件大小有两个明显的好处,一是可以减少存储空间,二是通过网络传输文件时,可以减少传输的时间.gzip是在Linux系统中经常使用的一个对文件进 行压缩和解压缩的命令,既方便又好用.gzip不仅可 ...
- linux常用命令(22)gzip命令
减少文件大小有两个明显的好处,一是可以减少存储空间,二是通过网络传输文件时,可以减少传输的时间.gzip是在Linux系统中经常使用的一个对文件进行压缩和解压缩的命令,既方便又好用.gzip不仅可以用 ...
- linux每日命令(1):gzip命令
gzip是在Linux系统中经常使用的一个对文件进行压缩和解压缩的命令,既方便又好用. gzip不仅可以用来压缩大的.较少使用的文件以节省磁盘空间,还可以和tar命令一起构成Linux操作系统中比较流 ...
- 每天一个linux命令(27)--tar命令
通过SSH访问服务器,难免会要用到压缩,解压缩,打包,解包等,这时候 tar 命令就是必不可少的一个功能强大的工具.Linux 中最流行的 tar 是麻雀虽小,五脏俱全. tar 命令可以为Linux ...
- tar linux 打包 压缩 gzip 命令说明
参数:-c :建立一个压缩档案的参数指令(create 的意思):-x :解开一个压缩档案的参数指令!-t :查看 tarfile 里面的档案! 特别注意,在参数的下达中, c/x/t ...
- Linux平台不同解压缩命令的使用方法
作者:郭孝星 微博:郭孝星的新浪微博 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells github:https://github.co ...
- 每天一个linux命令(32):gzip命令
减少文件大小有两个明显的好处,一是可以减少存储空间,二是通过网络传输文件时,可以减少传输的时间.gzip是在Linux系统中经常使用的一个对文件进行压缩和解压缩的命令,既方便又好用.gzip不仅可以用 ...
- 每天一个linux命令(24):gzip命令
减 少文件大小有两个明显的好处,一是可以减少存储空间,二是通过网络传输文件时,可以减少传输的时间.gzip是在Linux系统中经常使用的一个对文件进 行压缩和解压缩的命令,既方便又好用.gzip不仅可 ...
随机推荐
- 打造Android万能上拉下拉刷新框架--XRefreshView(三)
转载请注明出处:http://blog.csdn.net/footballclub/ 打造Android万能上拉下拉刷新框架–XRefreshView(一) 打造Android万能上拉下拉刷新框架–X ...
- Smali语法:数据类型、方法和字段
数据类型 dalvik字节码有两种类型,原始类型和引用类型.对象和数组是引用类型,其它都是原始类型. smali数据类型都是用一个字母表示,如果你熟悉Java的数据类型,你会发现表示smali数据类型 ...
- 创建标题栏,UINavigationBar的使用
IOS 开发有关界面的东西不仅可以使用代码来编写,也可以使用Interface Builder可视化工具来编写.今天有个朋友问我这两个有什么区别,首先说说IB ,使用它编辑出来的控件其实底层还是调用代 ...
- 工作总结 1 sql写法 insert into select from 2 vs中 obj文件和bin文件 3 npoi 模板copy CopySheet 最好先全部Copy完后 再根据生成sheet写数据 4 sheet.CopyRow(rowsindex, rowsindex + x); 5 npoi 复制模板如果出现单元格显示问题
我们可以从一个表中复制所有的列插入到另一个已存在的表中: INSERT INTO table2SELECT * FROM table1; 或者我们可以只复制希望的列插入到另一个已存在的表中: INSE ...
- different between method and function
A method is on an object. A function is independent of an object. For Java, there are only methods. ...
- Oracle SOA套件12c
产品概览 随着基于云的应用越来越多的被企业所採用,以及移动技术与企业应用的集成的需求的增多,企业级应用集成的复杂度也前所未有的提升. Oracle SOA套件12c,业内最完整的统一应用集成解决方式的 ...
- python常见面试题(一)
1.Python是如何进行内存管理的? 答:从三个方面来说,一对象的引用计数机制,二垃圾回收机制,三内存池机制 一.对象的引用计数机制 Python内部使用引用计数,来保持追踪内存中的对象,所有对象都 ...
- nodejs eclipse
nodejs下载地址 http://nodejs.org/1.下载并安装完nodejs后,打开cmd命令窗口,输入node -v,如果正确输出版本号,就是安装成功了,如果说node不是windows的 ...
- HTML DOM节点的增删改查
上篇博客中,我们已经初步接触了DOM基础,可是我们学习是为了可以更好地应用,今天我们就来看看DOM节点的增删改查. 无论在哪里,我们想要操作一个东西,总是应该先去获得它.那么我们怎么获得呢? HTML ...
- dedecms织梦如何调用指定的多个栏目导航
{dede:channelartlist row='2' typeid='1,2这里输入多个指定的栏目ID' } <li><a href='{dede:field name='typ ...