Why aren't the section titles of man pages completely greppable?

You can see what is happening if you view the raw codes within a man page. One way to do this is to export the man page to a file and inspect its contents directly:

man ls > man.ls
nano man.ls

The word "BUGS" actually looks like this in the file:

B^HBU^HUG^HGS^HS

You'll see that the headers contain formatting characters, so the entire word "BUGS" is not present.


If you want to access the plaintext contents of the manual page, you can use the command

man -P cat <thepage>

The -P option sets the pager on other unix and cat will ignore the formatting information, giving a plaintext output. However, this doesn't appear to work on macOS, so the output needs a manual col -b step in the pipeline:

man ls | col -b | grep BUGS