0

How to Search Man Pages in Terminal on the Mac

Posted by Melissa Holt on May 24, 2019
terminal search man page

The Mac’s Terminal program is a handy problem-solving tool, even after all of the iterations of macOS. I often use it to troubleshoot permissions problems, for example, or to see folders that aren’t normally accessible within the Finder. If you’re a Terminal user yourself, you’re probably familiar with the concept of man (which is short for “manual”) pages; these are basically help documents to guide us on how to use particular Terminal commands. You can get to one by typing man [command you want the definition for] at the command prompt, like so:
mac terminal prompt man
If you then press Return, the man page will open up within your Terminal window, and you can then read about your command until the cows come home. Seriously, some of those pages are just exhaustive (and a bit exhausting!).
When you want to progress to the next section of the man page, just scroll down with your mouse or trackpad or press the spacebar. To exit back to the command prompt, press the Q key on your keyboard.
But what if you’re looking for a specific bit of info within a man page and don’t want to have to read through the whole darned thing? Well, you can actually search man pages right from within Terminal, and here’s how you can do that!

  1. Open the Terminal program, which lives in your Applications > Utilities folder.
  2. As I did earlier, type “man” followed by the command for which you’d like to read the man page.
  3. mac terminal man grep

  4. Press Return, and then you’ll see the man page for that command.
  5. mac terminal grep man page

  6. Then press the forward slash (/) key followed by your search term, like this:
  7. mac terminal man search

  8. Press Return again, and Terminal will highlight all of the found instances of the term.

mac terminal man search results
You can then scroll up and down through the man page (or use your spacebar, as I mentioned) to see other places where the term appears. Another option would be to press the N key repeatedly to move to each match in the document.
Now, it’s important to note here that this search doesn’t follow the same rules that normal Terminal commands do in that you don’t have to do what’s called escaping spaces. In typical command usage, for example, referring to a file called “TekRevue Tip Ideas.jpg” would look like this…

TekRevue Tip Ideas.jpg

…which would tell Terminal that the upcoming spaces were part of the same filename as the previous word and not the beginning of a new command or argument. In the case of searching man pages, though, that isn’t necessary. You can just type in “/search term,” without having to put a backslash in front of that space. That’s pretty neat, but not escaping spaces feels wrong in the Terminal somehow. Almost like I’m blaspheming against the gods of BSD, and I’ll have to pray hard to escape their wrath. Heh. Get it? Escape?
I kill me.

Leave a Reply

Your email address will not be published. Required fields are marked *


Disclaimer: Some pages on this site may include an affiliate link. This does not effect our editorial in any way.