Debian

allpackages.txt.gz 有兩種不同的文件大小?

  • November 1, 2015

我看到了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?

編輯: How to find number of unique ‘applications’ in Debian jessie的後續問題

注意它對[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

引用自:https://unix.stackexchange.com/questions/159940