2

This question already has an answer here:

I find the manuals very difficult to read using the terminal. Is there a way to highlight specific text on the terminal? I tried piping to gedit using man man | gedit, but it opens a blank file instead.

Perhaps there's some way to find text within a man page and have it highlighted?

marked as duplicate by Anthon, rahmu, Zelda, terdon, jasonwryan Jan 18 '14 at 19:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Take a look at this U&L Q&A: Colors in Man Pages – slm Jan 18 '14 at 2:57
  • @slm, thanks, but that is syntax highlighting, different from what I want - highlighting specific text. – Question Overflow Jan 18 '14 at 3:38
  • Just hit / in the man page and then whatever you want to search for and enter. Hitting n moves to the next match and matches should be highlighted. – terdon Jan 18 '14 at 15:05
3

Dumping to clear text

You can use this technique to dump a man page out to a text file.

$ man -P cat ls > manpg_ls.txt

The above technique is just changing what pager man uses. Here we're telling it to use the cat command instead. We then get the man page for the ls command dumped to a file in clear text.

Example

Here's the first 10 lines of the ls man page.

$ man -P cat ls | head -10
LS(1)                                                              User Commands                                                             LS(1)



NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

Searching

Another approach is to use alternative pager commands and functions to search through man pages. Several techniques are covered in this U&L Q&A, titled: Reading and searching long man pages.

  • Thank you. I managed to find a simpler solution after pressing h for help. Sharing it here with everyone. – Question Overflow Jan 18 '14 at 8:13
  • @QuestionOverflow - re-read the link I gave you, the /some along with other techniques is covered over there. – slm Jan 18 '14 at 13:14
  • Indeed, I have to read that post the third time to realise that my answer could be found in the question itself because I misinterpret read to be some command. – Question Overflow Jan 19 '14 at 2:26
0

I managed to find a much simpler solution:

Once you have entered man page, type:

/some text

It does a case-insensitive search and highlight all occurrences of "some text". You can just page up or page down to scroll through the entire man page after that.

  • And if GNU less is your pager, you can type a Ctrl-K after the / to do the search in "Keep position" mode - it will highlight the matches without jumping ahead. – Wumpus Q. Wumbley Jan 18 '14 at 16:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.