Using the man command with grep piping

menguin

Geek
Pinoy Techie
So I have always known about man pages but never how to rock out with them or how to parse through them to understand them. Today I am going to show you something that when understood can help you find any command and quickly without google. If you understand grep and the conventions that man pages use you will be way better with Linux. The Linux/GNU operating system is google for Linux.

Try this:
1.) Lets say you want to find a command for checking your date of your system. Open a shell and type
man -k date
h
man calls the command and -k species a keyword which in our case is date. You should get back a bunch of results with numbers beside them like this. data(1) and timezone(1).

Example:
date (1) -write the date and time
fc-validate (3) blah bla

The number refers to the section in the man pages. There are 8 sections in man pages, usually we only want 1 and 8 as 1 is commands that user can run and 8 is system management commands. If you want to take a look at the convention sections you can type man man-pages. It's a good idea to understand the convention that all man pages use. To filter through these with Grep you can run.

man -k date | grep 1
date (1)
desktop (1)

This will show you only the commands in section 1.

From here you can run the command with man to get more info.
run: man date

From here the man pages should provide you with anything you need. Grep does a lot more than this, it can parse files and the system for specific info and when you really understand this stuff it will make Linux seem very simple.
 

Similar threads


Top Bottom