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

相关内容