linux 中用gzip 压缩目录步骤如下:
1、打开linux客户端。
❷ gzip怎么压缩和怎么解压缩文件到其他目录
解决:gzip -c test.txt > /root/test.gz,文件流重定向,解压也是,gunzip -c /root/test.gz > ./test.txt
经验:更常用的命令tar同样可以解压*.gz,参数为-c
附gzip帮助文件
GZIP(1) General Commands Manual GZIP(1)
NAME
gzip, gunzip, zcat - compress or expand files
SYNOPSIS
gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ]
gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ]
zcat [ -fhLV ] [ name ... ]
OPTIONS
-a --ascii
Ascii text mode: convert end-of-lines using local conventions.
This option is supported only on some non-Unix systems. For
MSDOS, CR LF is converted to LF when compressing, and LF is con‐
verted to CR LF when decompressing.
-c --stdout --to-stdout
Write output on standard output; keep original files unchanged.
If there are several input files, the output consists of a
sequence of independently compressed members. To obtain better
compression, concatenate all input files before compressing
them.
-d --decompress --uncompress
Decompress.
-f --force
Force compression or decompression even if the file has multiple
links or the corresponding file already exists, or if the com‐
pressed data is read from or written to a terminal. If the input
data is not in a format recognized by gzip, and if the option
--stdout is also given, the input data without change to
the standard output: let zcat behave as cat. If -f is not
given, and when not running in the background, gzip prompts to
verify whether an existing file should be overwritten.
-h --help
Display a help screen and quit.
-l --list
For each compressed file, list the following fields:
compressed size: size of the compressed file
uncompressed size: size of the uncompressed file
ratio: compression ratio (0.0% if unknown)
uncompressed_name: name of the uncompressed file
The uncompressed size is given as -1 for files not in gzip for‐
mat, such as compressed .Z files. To get the uncompressed size
for such a file, you can use:
zcat file.Z | wc -c
In combination with the --verbose option, the following fields
are also displayed:
method: compression method
crc: the 32-bit CRC of the uncompressed data
date & time: time stamp for the uncompressed file
The compression methods currently supported are deflate, com‐
press, lzh (SCO compress -H) and pack. The crc is given as
ffffffff for a file not in gzip format.
With --name, the uncompressed name, date and time are those
stored within the compress file if present.
With --verbose, the size totals and compression ratio for all
files is also displayed, unless some sizes are unknown. With
--quiet, the title and totals lines are not displayed.
-L --license
Display the gzip license and quit.
-n --no-name
When compressing, do not save the original file name and time
stamp by default. (The original name is always saved if the name
had to be truncated.) When decompressing, do not restore the
original file name if present (remove only the gzip suffix from
the compressed file name) and do not restore the original time
stamp if present ( it from the compressed file). This option
is the default when decompressing.
-N --name
When compressing, always save the original file name and time
stamp; this is the default. When decompressing, restore the
original file name and time stamp if present. This option is
useful on systems which have a limit on file name length or when
the time stamp has been lost after a file transfer.
-q --quiet
Suppress all warnings.
-r --recursive
Travel the directory structure recursively. If any of the file
names specified on the command line are directories, gzip will
descend into the directory and compress all the files it finds
there (or decompress them in the case of gunzip ).
-S .suf --suffix .suf
When compressing, use suffix .suf instead of .gz. Any non-empty
suffix can be given, but suffixes other than .z and .gz should
be avoided to avoid confusion when files are transferred to
other systems.
When decompressing, add .suf to the beginning of the list of
suffixes to try, when deriving an output file name from an input
file name.
pack(1).
-t --test
Test. Check the compressed file integrity.
-v --verbose
Verbose. Display the name and percentage rection for each file
compressed or decompressed.
-V --version
Version. Display the version number and compilation options then
quit.
-# --fast --best
Regulate the speed of compression using the specified digit #,
where -1 or --fast indicates the fastest compression method
(less compression) and -9 or --best indicates the slowest com‐
pression method (best compression). The default compression
level is -6 (that is, biased towards high compression at expense
of speed).
❸ 看看这个C#压缩代码..成功压缩,解压后没有后缀名
你指定文件的扩展名了吗?你用以下调用试试
CompressFile(@"c"my.txt",@"c:my.gzip");
通常用GZip压缩后的文件扩展名为 .gzip , WinRar、7-Zip等压缩软件可以识别.gzip并进行解压。
❹ 如何用C调用gzip实现自动压缩
命令: gzip语法:gzip [选项] 压缩(解压缩)的文件名 -c 将输出写到标准输出上,并保留原有文件。 -d 将压缩文件解压。 -l 对每个压缩文件,显示下列字段: (1)压缩文件的大小 (2)未压缩文件的大小 (3)压缩比 未压缩文件的名字 -r 递...
❺ 想在linux上用C实现gzip压缩与解压缩,有没有相关库函数可以调用
命令: gzip语法:gzip [选项] 压缩(解压缩)的文件名
-c 将输出写到标准输出上,并保留原有文件。
-d 将压缩文件解压。
-l 对每个压缩文件,显示下列字段:
(1)压缩文件的大小
(2)未压缩文件的大小
(3)压缩比
未压缩文件的名字
-r 递归式地查找指定目录并压缩其中的所有文件或者是解压缩。
-t 测试,检查压缩文件是否完整。
-v 对每一个压缩和解压的文件,显示文件名和压缩比。
-num 用指定的数字num调整压缩的速度,-1或--fast表示最快压缩方法(低压缩比),-9或--best表示最慢压缩方法(高压缩比)。系统缺省值为6。
注:gzip不能压缩整个目录。可以使用tar先打包,再压缩
例如:
$ tar cf test.tar test/
$ gzip test.tar
或
$ tar czf test.tar.gz test/
❻ gzip格式是啥
Gzip是一种内容压缩格式,现在大部份浏览器都可以浏览经过Gzip压缩过的内容
服务器将要输出的内容使用Gzip压缩后传给浏览器,这样可以达到提高网页的浏览速度和减少服务器网络带宽的使用,但同时多增加了在服务器端Gzip压缩内容的操作,所以会给服务器带来一定的负担...
GZIP最早由Jean-loup Gailly和Mark Adler创建,用于UNIX系统的文件压缩。我们在Linux中经常会用到后缀为.gz的文件,它们就是GZIP格式的。现今已经成为Internet 上使用非常普遍的一种数据压缩格式,或者说一种文件格式。HTTP协议上的GZIP编码是一种用来改进WEB应用程序性能的技术。大流量的WEB站点常常使用GZIP压缩技术来让用户感受更快的速度。
gzip 命令
减少文件大小有两个明显的好处,一是可以减少存储空间,二是通过网络传输文件时,可以减少传输的时间。gzip 是在 Linux 系统中经常使用的一个对文件进行压缩和解压缩的命令,既方便又好用。
语法:gzip [选项] 压缩(解压缩)的文件名
该命令的各选项含义如下:
-c 将输出写到标准输出上,并保留原有文件。
-d 将压缩文件解压。
-l 对每个压缩文件,显示下列字段:
压缩文件的大小;未压缩文件的大小;压缩比;未压缩文件的名字
-r 递归式地查找指定目录并压缩其中的所有文件或者是解压缩。
-t 测试,检查压缩文件是否完整。
-v 对每一个压缩和解压的文件,显示文件名和压缩比。
-num 用指定的数字 num 调整压缩的速度,-1 或 --fast 表示最快压缩方法(低压缩比),
-9 或--best表示最慢压缩方法(高压缩比)。系统缺省值为 6。
指令实例:
gzip *
% 把当前目录下的每个文件压缩成 .gz 文件。
gzip -dv *
% 把当前目录下每个压缩的文件解压,并列出详细的信息。
gzip -l *
% 详细显示例1中每个压缩的文件的信息,并不解压。
gzip usr.tar
% 压缩 tar 备份文件 usr.tar,此时压缩文件的扩展名为.tar.gz。
❼ 如何用C语言实现数据压缩
首先选择一个压缩算法
然后按照算法实现压缩代码,调用接口就可以
常见的 可以使用哈夫曼编码压缩,或者使用开源的压缩代码,比如lzo, gzip, lzma等等。
❽ 如何开启gzip压缩方法大全
IIS6.0启用Gzip压缩的方法:
1、新建Web服务扩展(如下图)
dll路径:“c:windowssystem32inetsrvgzip.dll”,然后启用。
2、网站服务中开启HTTP压缩支持(如下图)
临时目录需要给IIS用户读写权限。
3、修改IIS配置文件MetaBase.xml
文件路径:“c:windowssystem32inetsrv”(请先备份至他处),打开后搜索“HcDynamicCompressionLevel”,并修改(确定已备份)“Compression/deflate”和“Compression/gzip”两个片段的内容。下面的图n和图b所修改的内容用意是将js、css和php加入到压缩的范畴,数字9代表压缩等级。
(图n)
(图b)
4、重启IIS服务使之生效
——————————————————分分割割—————————————————
Apache启用Gzip压缩的方法:
1、开启模块并添加配置项目
a、vi /etc/httpd/conf/httpd.conf
b、查找LoadMole (/LoadMole),加入“LoadMole deflate_mole moles/mod_deflate.so”这行
c、添加配置项目(下段内容)
复制代码代码如下:
<IfMole mod_deflate.c>
# 压缩等级 9
DeflateCompressionLevel 9
# 压缩类型 html、xml、php、css、js
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript application/x-httpd-php
AddOutputFilter DEFLATE js css
</IfMole>
2、重启apache使之生效
service httpd start
——————————————————分分割割—————————————————
检测是否支持Gzip
END
注意事项
1. 在编辑MetaBase.xml前需要停止IIS,可以使用 net stop iisadmin
2. 修改完成后开启iisadmin服务,并执行iisreset命令
关于SEO的测试
压缩是否对SEO有影响,经测试,开启后仍然可以被很好的收录。
❾ 如何启用网页GZIP压缩
下面”舒宇卓创站长“将和大家一起分享一下,希望对咱们站长有所帮助! 1.开启网页GZIP压缩有什么好处? Gzip开启以后会将输出到用户浏览器的数据进行压缩的处理,这样就会减小通过网络传输的数据量,提高浏览的速度。 进而对于搜索引擎的收录也有一定的好处,也大大提高了我们的用户体验度。 2.如何启用IIS的Gzip压缩功能: 首先要有网站管理权限和服务器远程管理权限 步骤如下: 第一、如果你需要压缩静态文件(HTML),需要在硬盘上建一个目录,并给它“IUSR_机器名”这个用户的写权限。如果压缩动态文件(PHP,asp,aspx)就不需要了,因为它的页面是每次都动态生成的,压缩完就放弃。打开Internet信息服务(IIS)管理器,右击“网站”—>“属性”(注意:这里的网站是整个网站文件不是某个网站目录),之后选择“服务”。在“HTTP压缩”框中选中“压缩应用程序文件”和“压缩静态文件”,按需要设置“临时目录”和“临时目录的最大限制”。 第二、在Internet信息服务(IIS)管理器,右击“Web服务扩展”—>“增加一个新的Web服务扩展”,在“新建Web服务扩展”框中输入扩展名“HTTP Compression”,添加“要求的文件”为C:\WINDOWS\system32\inetsrv\gzip.dll,其中Windows系统目录根据您的安装可能有所不同,选中“设置扩展状态为允许”;这时候静态内容是可以压缩的,但是对于动态内容,aspx文件却不在压缩范围内。因为默认的可压缩文件并没有这个扩展名。而管理界面中你又找不到可以增加扩展名的地方,这时候只能去修改它的配置文件了。 第三、使用文本编辑器打开C:\Windows\System32\inetsrv\MetaBase.xml(建议先备份),查找 IIsCompressionScheme标签,有三个相同名字的段,分别是deflate,gzip,Parameters,第三段不用管它,前两段有基本相同的参数,HcDynamicCompressionLevel,设置压缩率,取值0~10,0不压缩,10最高压缩率,这里设置成9,9是性价比最高的一个。HcFileExtensions,需要压缩的静态文件扩展名,默认只有htm,html,txt,可以把js,css,xml添加进去。建议按原来的格式,用换行作为分隔。
❿ 请问如何用C语言写一个输入路径,压缩和解压文件的代码 能分享一下源码吗 我想学习一下
这个如果是在linux下面的话可以调用系统自带的压缩工具
大致给你说一下步骤吧。具体还是靠你自己实现
输入路径。这个就不多说。scanf
分析输入的文件路径,或者后缀名。然后调用 tar gzip等压缩,解压缩命令。
压缩的算法如果有兴趣你也可以自己去实现一下。不过不容易实现。还是调用系统自带的压缩命令吧。