0

I came across the post at How do I search for a word or a phrase in the Linux 'man' command and cycle through the found solutions? which explains the ability to cycle to the next pattern but how do I get it cycle through when it has passed the a pattern assuming it only occurs once or when I get to the bottom of the page?

For example once I have run the command man dpkg I pass / followed by simulate. This takes me to the pattern however it only works when I am the top of the page. If I am past the pattern, it does recursively search the entire man page.

PeanutsMonkey
  • 8,900
  • 36
  • 90
  • 133
  • The question you link to has the answer. Read the comments to the accepted answer. – Mat May 09 '12 at 05:43
  • Recursive doesn't mean what you think. – Daniel Beck May 09 '12 at 05:48
  • @Mat - I did read the accepted answer but it doesn't start from the top again if I have scrolled down to the bottom of the page. – PeanutsMonkey May 09 '12 at 05:56
  • @Daniel Beck - Sorry. What do you mean? – PeanutsMonkey May 09 '12 at 05:56
  • 1
    @PeanutsMonkey: The answer suggests just pressing `Home` or `p` to go to the beginning when you hit the end. The next search will then be from the beginning. `g` also works (and is similar to Vim, so that is what I use when in `less`). – Daniel Andersson May 09 '12 at 13:10
  • @Daniel Andersson - Thanks Daniel. Is there no way I can achieve it without pressing `Home` or `p`? – PeanutsMonkey May 10 '12 at 06:32
  • @PeanutsMonkey For some man pages I'm often reading and searching thru like `bash` I saved a copy to a textfile with `man bash | col -b >bash.txt` and then `vi bash.txt`. A disadvantage is you need to redo that when a new version of bash is installed. – ott-- May 10 '12 at 10:21

1 Answers1

1

man does not have an option to continue searching at the top of page once you reach the bottom, so pressing p is your option, or Shift-n to search backwards.

man uses less to do its paging, and less doesn't support cycling that way. So you could look at getting man to use something other than less for paging such as vim. Or alternatively, install the vim man plugin and run man from within a vim session:

:Man dpkg
Paul
  • 59,223
  • 18
  • 147
  • 168