導航:首頁 > 文件處理 > c壓縮gzip

c壓縮gzip

發布時間:2022-08-09 14:15:27

linux 中 用gzip 如何壓縮目錄

linux 中用gzip 壓縮目錄步驟如下:

1、打開linux客戶端。

❷ gzip怎麼壓縮和怎麼解壓縮文件到其他目錄

  1. 解決:gzip -c test.txt > /root/test.gz,文件流重定向,解壓也是,gunzip -c /root/test.gz > ./test.txt

  2. 經驗:更常用的命令tar同樣可以解壓*.gz,參數為-c

  3. 附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下面的話可以調用系統自帶的壓縮工具

大致給你說一下步驟吧。具體還是靠你自己實現

  1. 輸入路徑。這個就不多說。scanf

  2. 分析輸入的文件路徑,或者後綴名。然後調用 tar gzip等壓縮,解壓縮命令。

壓縮的演算法如果有興趣你也可以自己去實現一下。不過不容易實現。還是調用系統自帶的壓縮命令吧。

閱讀全文

與c壓縮gzip相關的資料

熱點內容
演算法申請著作權 瀏覽:213
以前手機號換了要怎麼登錄農行app 瀏覽:192
線切割編程系統怎麼繪畫 瀏覽:234
如何搭建雲伺服器異地容災 瀏覽:923
黃金拐點指標源碼 瀏覽:91
演算法導論第九章 瀏覽:276
鴿子為什麼生成伺服器沒反應 瀏覽:490
freebsdnginxphp 瀏覽:215
雜訊消除演算法 瀏覽:608
vue類似電腦文件夾展示 瀏覽:112
後備伺服器有什麼功效 瀏覽:269
連不上伺服器怎麼連 瀏覽:600
什麼構架的可以刷安卓系統 瀏覽:771
愛奇藝APP怎麼兌換CDK 瀏覽:994
程序員買4k顯示器還是2k顯示器 瀏覽:144
python多進程怎麼多窗口 瀏覽:818
電腦文件夾怎麼取消類別 瀏覽:47
cad拉線段命令 瀏覽:924
如何用電腦清理手機沒用的文件夾 瀏覽:100
儲存層次結構對程序員的意義 瀏覽:477