Ubuntu: How to redirect all manuals to files?


Just for fun, or say for sake of convenience, I decided to write out all man pages to files.

Now if I have to do it one by one, I would do man package-name > filename. But I want to do some smart work and write all mans at once, either by using single command or by a bash script.All that I have come up with till now is

cd /usr/share #you may use any folder  whereis -m * | grep '.gz' |awk '{print$1}' |sed s/://g  

This gives an output, naming all applications having man pages.Some part of it is as below.

speech-dispatcher  stellarium  synaptic  syslinux  system-config-printer  tabset  terminfo  totem  ufw  unetbootin  unity  unity-greeter  update-manager  upstart  usb_modeswitch  vim  virtualbox  vlc  xmms2  xpdf  yelp  zenity  

Now, what I need to do is redirect this output to man so that I could redirect it to files.Once I do this, then I may create a script to cd to every folder and check for mans.

So my question is, how do I achieve this?

OR, maybe an alternate way exists?

I'm using Ubuntu 12.10.

Please migrate it to stackoverflow if it's appropriate there.Though I think it's more appropriate here.


There are many executables in /bin. If you want to copy their corresponding man pages into files, you use something like this in your terminal

for f in /bin/*;do man $(basename $f) > $HOME/man_$(basename $f); done  

After execution of the command you will find all the man pages corresponds to the executables in /bin/ in your home. For example man page corresponds to ls will take name man_ls.txt inyour home.

If you want copy only a part, say the executables name begins with r, use,

for f in /bin/r*;do man $(basename $f) > $HOME/man_$(basename $f); done  

You may get several note like,

No manual entry for <some_executable>  See 'man 7 undocumented' for help when manual pages are not available.  

for the executables which does not have a man entry.

Do this for other folders which contains executables like, /usr/bin/ ,/usr/sbin/ ,/sbin/ etc.


you can use 2>/dev/null with your command to suppress the error messages for executables without man entry. like,

for f in /usr/bin/r*;do man $(basename $f) > $HOME/man_$(basename $f) 2>/dev/null; done  

According to your approach

Navigate to a folder and use this for the same result,

for f in $(whereis -m * | grep '.gz' |awk '{print$1}' |sed s/://g); do man $f > $HOME/man_$f.txt; done  


First off, why would you want a file containing all the man pages? If it is to facilitate searching through all of them for some keyword, GNU already provides apropos for just that:

apropos some-regular-expression  

returns a list of all man pages matching the regular expression in their name or description.

Anyway, if you still want the encyclopedic file, then making use of apropos, you can obtain a list of all man pages on the system by searching for the universal regular expression:

apropos '.*'  

then feed the resulting list into the man command:

apropos '.*' | awk '{print $1;}' | xargs man > all-manpages.txt  

You could also use the method described in the answer to the similar question "Generate a list of all available commands and what each does", replacing whatis by man.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »