解決: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).
② 如何開啟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 與zip區別
一、主體不同
1、GZIP:最早由Jean-loup Gailly和Mark Adler創建,用於UNⅨ系統的文件壓縮。
2、ZIP:ZIP文件格式是一種數據壓縮和文檔儲存的文件格式。
二、特點不同
1、GZIP:基礎是DEFLATE,DEFLATE是LZ77與哈夫曼編碼的一個組合體。DEFLATE最初是作為LZW以及其它受專利保護的數據壓縮演算法的替代版本而設計的。
2、ZIP:是一種相當簡單的分別壓縮每個文件的存檔格式。分別壓縮文件允許不必讀取另外的數據而檢索獨立的文件。
三、優點不同
1、GZIP:可以減少存儲空間,通過網路傳輸文件時,可以減少傳輸的時間。
2、ZIP:支持基於對稱加密系統的一個簡單的密碼,已知有嚴重的缺陷,已知明文攻擊,字典攻擊和暴力攻擊。
④ 如何進行網站的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添加進去。建議按原來的格式,用換行作為分隔。
⑤ zip壓縮和gzip壓縮有何區別,各有什麼優點謝謝!
gzip是linux下面用的格式,一般在Linux下解壓,如果用Windows下的程序解壓有可能丟失其中某些文件或屬性。
⑥ 網站建設中的gzip壓縮是什麼意思
GZIP格式已經成為使用非常普遍的一種數據壓縮格式,或者說一種文件格式。HTTP協議上的GZIP編碼是一種用來改進WEB應用程序性能的技術。大流量的WEB站點常常使用GZIP壓縮技術來讓用戶感受更快的速度。減少文件大小有兩個明顯的好處,一是可以減少存儲空間,二是通過網路傳輸文件時,可以減少傳輸的時間。gzip 是在 Linux 系統中經常使用的一個對文件進行壓縮和解壓縮的命令,既方便又好用。
另外,你建的如果不是大型站點。只是一個企業站或一個小社區小門戶不需要用這個技術。只需要把代碼優化做好一點選個速度快一點的伺服器就行了。我做網站滴
⑦ 什麼是GZIP壓縮 網頁GZIP壓縮是什麼意思
這一般是指WWW伺服器中安裝的一個功能,當有人來訪問這個伺服器中的網站時,伺服器中的這個功能就將網頁內容壓縮後傳輸到來訪的電腦瀏覽器中顯示出來.一般對純文本內容可壓縮到原大小的40%.這樣傳輸就快了,效果就是你點擊網址後會很快的顯示出來.當然這也會增加伺服器的負載.
一般伺服器中都安裝有這個功能模塊的.
⑧ 怎樣調用Gzip將指定的文件進行壓縮並備份(
命令: gzip語法:gzip [選項] 壓縮(解壓縮)的文件名 -c 將輸出寫到標准輸出上,並保留原有文件。 -d 將壓縮文件解壓。 -l 對每個壓縮文件,顯示下列欄位: (1)壓縮文件的大小 (2)未壓縮文件的大小 (3)壓縮比 未壓縮文件的名字 -r 遞...
⑨ gzip壓縮 是什麼
這一般是指WWW伺服器中安裝的一個功能,當有人來訪問這個伺服器中的網站時,伺服器中的這個功能就將網頁內容壓縮後傳輸到來訪的電腦瀏覽器中顯示出來.一般對純文本內容可壓縮到原大小的40-70左右%.這樣傳輸就快了,效果就是你點擊網址後會很快的顯示出來.當然這也會增加伺服器的負載.一般伺服器中都安裝有這個功能模塊的.
網站的訪問速度是由多個因素所共同決定的,這些因素例如應用程序的響應速度、網路帶寬、伺服器性能、與客戶端之間的網路傳輸速度等等。其中最重要的一個因素是應用程序本身的響應速度,因此當你為網站性能所苦惱時,你第一個需要著手進行處理的便是盡可能的提升應用程序的執行速度,你可以使用緩存或者是優化代碼的執行效率來提升應用程序的速度。
在確保您的應用程序的性能已經達到足夠好,同時伺服器的性能也完全滿足的情況下,不妨來試試網頁壓縮來進一步提升網頁的瀏覽速度,而且非常重要的是,它完全不需要任何的成本,只不過是會讓您的伺服器CPU佔用率稍微提升一兩個百分點而已或者更少。
網頁壓縮是一項由 WEB 伺服器和瀏覽器之間共同遵守的協議,也就是說 WEB 伺服器和瀏覽器都必須支持該技術,所幸的是現在流行的瀏覽器都是支持的,包括 IE、FireFox、Opera 等;伺服器有 Apache 和 IIS 等。雙方的協商過程如下:
1.首先瀏覽器請求某個 URL 地址,並在請求的頭 (head) 中設置屬性 accept-encoding 值為 gzip, deflate,表明瀏覽器支持 gzip 和 deflate 這兩種壓縮方式(事實上 deflate 也是使用 gzip 壓縮協議);
2.WEB 伺服器接收到請求後判斷瀏覽器是否支持壓縮,如果支持就傳送壓縮後的響應內容,否則傳送不經過壓縮的內容;
3.瀏覽器獲取響應內容後,判斷內容是否被壓縮,如果是則解壓縮,然後顯示響應頁面的內容。
在實際的應用中我們發現壓縮的比率往往在 3 到 10 倍,也就是本來 50k 大小的頁面,採用壓縮後實際傳輸的內容大小隻有 5 至 15k 大小,這可以大大節省伺服器的網路帶寬,同時如果應用程序的響應足夠快時,網站的速度瓶頸就轉到了網路的傳輸速度上,因此內容壓縮後就可以大大的提升頁面的瀏覽速度。
⑩ linux 中 用gzip 如何壓縮目錄
linux 中用gzip 壓縮目錄步驟如下:
1、打開linux客戶端。