I want to output the name of the installed software package that owns the greatest number of system manual pages. Is there a command to do this?
4 Answers
For Debian-based systems, to get the package with the most installed man pages:
dpkg -S '/usr/share/man/*.gz' | cut -d: -f1 | sort | uniq -c | sort -rn | head -1 | awk '{print $2}'
To get the package with the most available man pages (whether installed or not):
apt-file search /usr/share/man | cut -d: -f1 | uniq -c | sort -rn | head -1 | awk '{print $2}'
On my system, the package with the most available man-pages is linux-manual-3.2
.
Explanation
Taking the pipeline used to create pkg
one step at a time:
apt-file search /usr/share/man
This returns the packages and file names for all files in
/usr/share/man
hierarchy.cut -d: -f1
This removes the file names for the list so that we just have a list of packages.
uniq -c
This counts the number of man pages in each package. (Often, one needs to sort before using
uniq -c
butapt-find
produces output one package at at time making that step unnecessary.)sort -rn
This does a numeric sort in descending order so that the package with the most man pages is at the top and those with the least are at the bottom.
head -1
This picks the first line which the one with the most man pages.
awk '{print $2}'
This selects the package name from that line.
I found it interesting to use just a part of this pipeline:
apt-file search /usr/share/man | cut -d: -f1 | uniq -c | sort -rn | less
This displays, via less
, the list of packages sorted in descending order by number of man pages. On my system, the top five are:
3453 linux-manual-3.2
3384 liblapack-doc-man
2350 freebsd-manpages
1916 manpages-ja-dev
1905 manpages-fr-dev
-
Thans for providing the information on how to find the package in debian based systems. I appreciate it.– RameshSep 2, 2014 at 20:45
-
1Doesn't
apt-file search
search among all available packages? wouldn't something likedpkg -S /usr/share/man/*.gz
provide an answer closer to "the name of the installed software package that ..." Sep 2, 2014 at 21:42 -
@steeldriver Thanks. Yes, that matches the OP's intent better. Answer updated.– John1024Sep 2, 2014 at 22:28
On my gentoo box command
qfile /usr/share/man/*/* | awk '{print $1}' | sort | uniq -c | sort -n
gives
864 sys-libs/ncurses
1139 sys-apps/man-pages-posix
1283 dev-libs/openssl
2209 sys-apps/man-pages
2246 x11-libs/libxcb
But after including all subdirectories with a little help of **
pattern
qfile /usr/share/man/**/* | awk '{print $1}' | sort | uniq -c | sort -n
man-pages wins:
933 sys-libs/ncurses
1142 sys-apps/man-pages-posix
1352 dev-libs/openssl
2254 x11-libs/libxcb
2310 sys-apps/man-pages
-
qfile is a gentoo only command, and while I use Gentoo also, this answer is invalid, as we should use sed or awk, so they work on all variants. Sep 2, 2014 at 21:42
-
You cannot use sed or awk to determine to which package file belongs, unless you want to parse package manager. That's the whole point. You must use
qfile
in gentoo or as others pointed outapt-file
in debian orrpm
in RH etc.– jimmijSep 2, 2014 at 21:53
Alternative for Debian/Ubuntu/Mint...
$ cd /var/lib/dpkg/info &&
grep -c '^/usr/share/man/.*/' *.list | sort -t: -k2rn | less -XF
Gives for me:
manpages-dev.list:1962
libssl-doc.list:1171
tcl8.6-doc.list:813
perl-doc.list:719
libdatetime-locale-perl.list:470
tcllib.list:407
This solution worked on CentOS and RHEL machines.
rpm -qf $(man -w $(compgen -ac)) | sort | uniq -c | sort -nr | head -1
I can generate the list of all the commands that are available in the system using compgen -ac
. Now, man -w
can tell the corresponding man page of this command.
I give this man page as input to rpm -qf
which will give me the package which owns it. Now, I sort the output and then find the total occurrences and then get the first line which will give me the package name with the count of man pages corresponding to this package. After I run the above command, the output that I get is,
329 netpbm-progs-10.47.05-11.el6.x86_64
So, the above output indicates that I have 329 manual page entries for the commands provided by the package netpbm-progs-10.47.05-11.el6.x86_64
which is the highest in my system.
References
sort -V
can be very helpful. It orders by versions, so there is no need to parse data, etc.