0

I stumbled over this problem with the following simplified example:

man zsh|grep zshparam

produces no output, even though the zsh-manpage contains pretty close to the top the string zshparam. Investigating the problem with

man zsh|xxd

it occured to me that the man-output is formatted (groff ?), and the string zshparam is represented in the man-page output as

00000210: 616e 7369 6f6e 0a20 2020 2020 2020 5f08  ansion.       _.
00000220: 7a5f 0873 5f08 685f 0870 5f08 615f 0872  z_.s_.h_.p_.a_.r
00000230: 5f08 615f 086d 2020 2020 205a 7368 2070  _.a_.m     Zsh p
00000240: 6172 616d 6574 6572 730a 2020 2020 2020  arameters.

man has dutifully inserted formatting code so that the word zshparam is nicely displayed in bold, and of course grep can't find it. In the Linux implementation of man, this styling is AFIK turned off if the stdout of man goes to a pipe, but this is obviously not the case in BSD-man.

Is there a way to persuade man not to style its output, or is there a utility which can remove this styling information from the generated man-page?

3
  • I'm voting to close this question because of apple.stackexchange.com/questions/196806/… A lot of good info there. In short you can man zsh | col -b | grep zshparam Commented Jul 6, 2023 at 12:55
  • @MateuszSzlosek : Thanks for the link. Indeed col -b does the job. BTW, the other solution recommended on this page (i.e. man -t) did not work for my case; the resulting output still seems to contain the raw troff code. Commented Jul 6, 2023 at 13:04
  • Instead of fighting man why not use less 's search feature. Using your example- man -P "less -p zshparam" zsh.
    – fd0
    Commented Jul 13, 2023 at 13:34

0

Browse other questions tagged .