allpackages.txt.gz 有兩個不同的檔案大小?

allpackages.txt.gz 有兩個不同的檔案大小?

我看見http://linux.koolsolutions.com/2008/12/19/counting-number-of-packages-under-debian-linux/我想計算測試中的包數量。

我嘗試了其中共享的內容:-

http://packages.debian.org/testing/allpackages?format=txt.gz
Resolving packages.debian.org (packages.debian.org)... 5.153.231.3, 2001:41c8:1000:21::21:3, 2001:8d8:880:901::1a1:4
Connecting to packages.debian.org (packages.debian.org)|5.153.231.3|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://packages.debian.org/testing/allpackages?format=txt.gz [following]
--2014-10-08 01:52:54--  https://packages.debian.org/testing/allpackages?format=txt.gz
Connecting to packages.debian.org (packages.debian.org)|5.153.231.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1039782 (1015K) [text/plain]
Saving to: ‘allpackages?format=txt.gz’

100%[======================================================================================================>] 10,39,782   64.0KB/s   in 13s    

$ mv allpackages\?format=txt.gz allpackages.txt.gz

$ gunzip allpackages.txt.gz

$ ll -h allpackages.txt 
-rw-r--r-- 1 shirish shirish 4.9M Oct  7 23:53 allpackages.txt

但是,如果我嘗試獲取所有包而不壓縮它,我會得到以下資訊:-

$ wget http://packages.debian.org/testing/allpackages
--2014-10-08 01:52:11--  http://packages.debian.org/testing/allpackages
Resolving packages.debian.org (packages.debian.org)... 5.153.231.3, 2001:41c8:1000:21::21:3, 2001:8d8:880:901::1a1:4
Connecting to packages.debian.org (packages.debian.org)|5.153.231.3|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://packages.debian.org/testing/allpackages [following]
--2014-10-08 01:52:11--  https://packages.debian.org/testing/allpackages
Connecting to packages.debian.org (packages.debian.org)|5.153.231.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10110498 (9.6M) [text/html]
Saving to: ‘allpackages’

 9% [========>                                                                                              ] 9,49,116    55.5KB/s  eta 1m 48s 
Terminated

知道為什麼這兩個計數之間的位元組大小差異超過 100% 嗎?一個 4.9 MB,另一個 9.6 MB?

編輯:後續問題如何在 Debian jessie 中找到獨特「應用程式」的數量

答案1

請注意它是如何表示[text/html]第二個的,而不是[text/plain]。您不是在獲取軟體包列表,而是在獲取一個網頁包含包列表,以及一堆其他格式。

但實際上,您想要取得壓縮版本;它將節省您和 Debian 的時間和金錢。您可以使用一個命令來完成此操作:

wget 'http://packages.debian.org/testing/allpackages?format=txt.gz' -O - | gunzip > allpackages.txt

或直接計算行數(但請注意,由於文件開頭有額外的行,這會略有偏差):

wget 'http://packages.debian.org/testing/allpackages?format=txt.gz' -O - | gunzip | wc -l

相關內容