How To Discover Longest Man Web page In Linux

0

Get real time updates directly on you device, subscribe now.

All instructions’ man pages are saved in /usr/share/man/ listing in Linux. The person pages compressed in gzip (.gz) format. Curious to know which command has the most important handbook web page in your Linux system? Right here greatest means, I’m speaking concerning the variety of strains in a person web page. It isn’t concerning the file measurement or quantity pages when printed. Should you ever questioned how one can discover longest man web page in Linux and Unix distributions, observe any one of many strategies given right here.

How To Discover Longest Man Web page In Linux

We will discover the most important and longest man pages by counting the variety of strains and phrases in them. The wc command is used to depend variety of strains and phrases in a file. As an illustration, to depend the variety of strains in ls command’s man web page, run:

$ man ls | wc -l

Equally, to depend the variety of phrases in ls man web page, use -w flag like beneath.

$ man ls | wc -w

Find number of lines and words in a man page in linux

Nevertheless, counting the variety of strains in every man web page is tedious, time consuming and doubtless a dumb thought to seek out out longest man pages in the entire system. We will simply discover this utilizing a for loop like beneath.

for i in ; do f=/usr/share/man/man$i/$(ls -1S /usr/share/man/man$i/ | head -n1); printf “%s: %9dn” “$f” $(man “$f” 2>/dev/null | wc -l); executed

This command will analyze man directories (1 to eight) and show the longest man web page in every listing in descending order. It’s going to take a couple of minutes relying upon the variety of man pages in your system.

Right here is the output from my Ubuntu 18.04 system:

/usr/share/man/man1/ffmpeg-all.1.gz: 25468
/usr/share/man/man2/perf_event_open.2.gz: 1732
/usr/share/man/man3/Web::SSLeay.3pm.gz: 8738
/usr/share/man/man4/st.four.gz: 423
/usr/share/man/man5/proc.5.gz: 3087
/usr/share/man/man6/espdiff.6.gz: 50
/usr/share/man/man7/groff_mdoc.7.gz: 1826
/usr/share/man/man8/dnsmasq.Eight.gz: 1337

Find Longest Man Page In Linux And Unix

As you may see, the longest man web page is ffmpeg-all with 25468 strains in complete.

You’ll be able to cross test it with wc command like beneath.

$ man ffmpeg-all | wc -l
25468

If you wish to discover the longest man based mostly on variety of phrases as an alternative of strains, run:

for i in ; do f=/usr/share/man/man$i/$(ls -1S /usr/share/man/man$i/ | head -n1); printf “%s: %9dn” “$f” $(man “$f” 2>/dev/null | wc -w); executed

Pattern output:

/usr/share/man/man1/ffmpeg-all.1.gz: 130475
/usr/share/man/man2/perf_event_open.2.gz: 11031
/usr/share/man/man3/Web::SSLeay.3pm.gz: 37886
/usr/share/man/man4/st.four.gz: 4358
/usr/share/man/man5/proc.5.gz: 22939
/usr/share/man/man6/espdiff.6.gz: 294
/usr/share/man/man7/groff_mdoc.7.gz: 11919
/usr/share/man/man8/dnsmasq.Eight.gz: 16875

Test whether it is right utilizing command:

$ man ffmpeg-all | wc -w
130475

A easy Script To Discover Longest Man Web page In Linux

Right here is an easy BASH script to seek out the longest man web page in a Linux system.

Create a file, for instance longman.sh (quick for longest man web page):

$ nano longman.sh

Add the next strains in it:

#!/usr/bin/env bash
cd /usr/share/man/
for fn in $(discover -maxdepth 1 -type d -iname ‘man[1-8]’); do
fn=$fn#./
ls -1Sp “$fn” | head -n 10 | sed -Ee “s,^,$PWD/$fn/,” | whereas learn manpage; do
shortname=$(echo “$manpage” | sed -e “s,$PWD/man,,” -e “s,/,”$’t'”,”)
printf ‘%9dtpercentsn’ $(man “$manpage” 2>/dev/null | wc -l) “$shortname”
executed
executed | kind -n

If you wish to depend variety of phrases as an alternative of strains, use wc -w within the above script. This script takes the highest 10 in each man dir, compiles a desk and types it by the variety of strains. It additionally excludes any of the numbered sections 1-Eight in the event that they do NOT exist in your system.

Save and shut the file and make it executable utilizing command:

$ chmod +x longman.sh

Now, run this script to seek out the longest man web page in your system:

$ ./longman.sh

The longest man web page is displayed on the backside. If you wish to show longest man web page on the highest, use “kind -rn” within the above script.

Pattern output:

[…]
14236 1 ffmpeg-filters.1.gz
15470 1 x86_64-linux-gnu-g++-7.1.gz
15470 1 x86_64-linux-gnu-gcc-7.1.gz
20579 1 ffplay-all.1.gz
20797 1 ffprobe-all.1.gz
24856 1 ffserver-all.1.gz
25468 1 ffmpeg-all.1.gz

A Bash Script To Find Longest Man Page In Linux

The quantity within the center signifies the man web page part.

To know extra particulars about man pages, run:

$ man man
$ man -k man
$ information man

Prompt learn:

Hope this was helpful.

Thanks for stopping by!

Assist us that can assist you:

Have a Good day!!

Source link

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More