Is there an easy way to find out which command has the longest manual pages?
-
most commands have only one manual page. Are you looking for the top 10 (e.g.) biggest manual pages? Based on what criteria? File size, number of pages when printed, original troff input size?– AnthonOct 9, 2014 at 12:12
-
@Anthon I changed biggest to longest, perhaps it is better word here. My original intention was number of lines, but if you think other things are more relevant feel free to post an answer, I will upvote all relevant answers. I was just curious and google didn't help to find answer to that question.– WeSenseASoulInSearchOfAnswersOct 9, 2014 at 12:35
4 Answers
You can calculate it yourself for your system with simple command
$ find /usr/share/man/ -type f -exec ls -S {} + 2>/dev/null | head | while \
read -r file; do printf "%-40s" "$file"; \
man "$file" 2>/dev/null | wc -lwm; done | sort -nrk 4
which returns on my box
(file) (lines) (words) (chars)
/usr/share/man/man1/zshall.1.bz2 27017 186394 1688174
/usr/share/man/man1/cmake.1.bz2 22477 106148 1004288
/usr/share/man/man1/cmake-gui.1.bz2 21362 100055 951110
/usr/share/man/man1/perltoc.1.bz2 18179 59783 780134
/usr/share/man/man1/cpack.1.bz2 9694 48264 458528
/usr/share/man/man1/cmakemodules.1.bz2 10637 42022 419127
/usr/share/man/man5/smb.conf.5.bz2 8306 49991 404190
/usr/share/man/man1/perlapi.1.bz2 8548 43873 387237
/usr/share/man/man1/perldiag.1.bz2 5662 37910 276778
/usr/share/man/e 1518 5919 58630
where columns represent number of lines, words and characters respectively. Rows (commands) are sorted by last column.
We can do similar thing for info pages, but we have to bear in mind that it's content can span over many files. Thus let's use the benefits of zsh
to keep above one-liner in compact form:
$ for inf in ${(u)$(echo /usr/share/info/**/*(.:t:r:r))}; do \
printf "%-40s" "$inf"; \
info "$inf" 2>/dev/null | wc -lwm; done | sort -nrk 4
what gives
(info title) (lines) (words) (chars)
elisp 72925 457537 3379403
libc 69813 411216 3066817
lispref 62753 374938 2806412
emacs 47507 322194 2291425
calc 33716 244394 1680763
internals 32221 219772 1549305
zsh 34932 206851 1544909
gsl-ref 32493 179954 1518248
gnus 31723 180613 1405064
gawk 27150 167135 1203395
xemacs 25734 170403 1184250
Info pages are huge mostly for gnu-related stuff what is understandable, but I find interesting that for example zsh has more lines and words but less characters than in man pages. It is interesting because at first glance the content is the same, just formatting is a little bit different.
Explanation of zsh tricks in the selection of the files for the loop: for inf in ${(u)$(echo /usr/share/info/**/*(.:t:r:r))}; do
The goal is to create the list of unique file names from /usr/share/info directory and all subdirectories. Files should be stripped from dirname, extenstions and all numbers. The above snippet can be rewritten as ${(u)$(echo /usr/share/info/**/*(.)):t:r:r}
, what gives the same result but uses probably more decent syntax, namely:
**/*
: descent into all subdirectories and mark everything there(.)
: select only plain files:t
: remove pathname components (works likebasename
):r
: remove extension (everything after last dot, including dot). It is applied twice to remove also unnecessary string and number (e.g..info-6
from filezsh.info-6.bz2
)(u)
: show only unique words (after previous operations there are many the same words - different files/chapters for the same info command)
-
1
-
move the "| head" to the end of that impressive pipeline if you really want "the longest" man pages (and prepare to wait quite a bit longer) Dec 4, 2016 at 18:13
Man pages are stored in /usr/share/man/manX
where X
is the section (described in man man
). They're compressed in gzip format, so let's assume a larger compressed file means a bigger manpage.
By checking in /usr/share/man/man1
(section 1: Executable programs or shell commands) with the command gzip -l *.gz | sort -n -k2
, I get this (which will probably vary from distro to distro, this was on an Arch Linux system with a bunch of packages) where the first column is the compressed file size and the second column is the uncompressed file size:
161077 607106 73.5% ffprobe-all.1
198943 757155 73.7% ffserver-all.1
217339 792577 72.6% msp430-g++.1
217339 792577 72.6% msp430-gcc.1
209129 794118 73.7% ffmpeg-all.1
261778 972719 73.1% avr-g++.1
261778 972719 73.1% avr-gcc.1
262154 975423 73.1% g++.1
262154 975423 73.1% gcc.1
227830 1123043 79.7% perltoc.1perl
An alternative to the methods provided by @Renan and @jimmij yields wireshark-filter
the big winner on my system.
for i in {1..9}; do du -sh man"$i"/*.gz | grep -v "^..0K" | grep -v "^0\|^12K\|^16K\|^[0-9][0-9]K" ; done
Based on that I did a opened each of the largest entries with man
and checked the number of lines at the end of the file with a :f
and came up with:
wireshark-filter = 245016 lines
gcc = 8341 lines
perlfunc = 5132 lines
The example by @jimmij is interesting, but incorrect because it returns results from only one subdirectory. Running that script (on my Debian 7), I get this:
/usr/share/man/man3/DBI.3pm.gz 6182 35812 271206
/usr/share/man/man8/openvpn.8.gz 4021 24702 202032
/usr/share/man/pt/man1/nmap.1.gz 2563 21214 159284
/usr/share/man/man8/lsof.8.gz 2714 18670 142698
/usr/share/man/man3/pcrepattern.3.gz 2579 18631 131204
/usr/share/man/man3/pcreapi.3.gz 2382 16966 123349
/usr/share/man/man8/iptables.8.gz 2631 14844 114354
/usr/share/man/man8/ip6tables.8.gz 2465 13619 105283
/usr/share/man/man3/CPAN.3perl.gz 2142 12346 98823
/usr/share/man/man8/mount.8.gz 2136 12059 97407
Here's a quick revision which fixes that problem:
find /usr/share/man/ -type f -ls | \
awk '{ printf "%s %s\n", $7, $11; }' | \
sort -r -n 2>/dev/null | \
awk '{ printf "%s\n", $2; }' 2>/dev/null | head -n 20 |
while \
read -r file; do printf "%-40s" "$file"; \
man "$file" 2>/dev/null | wc -lwm; done | sort -nrk 4
On my Debian 7 system that gives
/usr/share/man/man1/cmake.1.gz 19264 86499 803021
/usr/share/man/man1/perltoc.1.gz 18755 62738 657990
/usr/share/man/man1/fvwm2.1.gz 8942 57060 462861
/usr/share/man/man1/cmakemodules.1.gz 9843 37965 376314
/usr/share/man/man1/perlfunc.1.gz 7535 47684 370246
/usr/share/man/man5/smb.conf.5.gz 8303 49962 359329
/usr/share/man/man1/cpack.1.gz 8037 38214 342264
/usr/share/man/man1/bash.1.gz 5465 42031 320015
/usr/share/man/man1/perlapi.1.gz 7074 36791 309196
/usr/share/man/man1/xterm-dev.1.gz 6242 34747 297639
/usr/share/man/man3/DBI.3pm.gz 6182 35812 271206
/usr/share/man/man1/xterm.1.gz 5238 29434 253526
/usr/share/man/man1/zshcompsys.1.gz 4502 31336 244115
/usr/share/man/man1/perldiag.1.gz 4939 33200 237882
/usr/share/man/man1/tcsh.1.gz 4355 29640 226498
/usr/share/man/ru/man1/nmap.1.gz 3048 21396 187181
/usr/share/man/hu/man1/nmap.1.gz 3020 21519 186431
/usr/share/man/de/man1/nmap.1.gz 2965 21384 182926
/usr/share/man/man1/nmap.1.gz 3005 24785 179485
/usr/share/man/ru/man1/mc.1.gz 3571 19200 173292
For what it's worth, there are 10326 files under /usr/share/man
on that machine (ymmv).