1

For exmaple, I open man page of tar and I want to locate -z quickly.

But when I type /-z, things like -i, --ignore-zeros also get matched. So I have to press n several times to reach -z.

However, I tried /-z$ or /^-z$ but neither works.

2

^ and $ in this context refer to the start and end of a complete line - what you need is a word boundary:

/-z\b

   -z, --gzip, --gunzip, --ungzip
          Filter the archive through gzip(1).

   -Z, --compress, --uncompress
          Filter the archive through compress(1).

If you also want to exclude the upper case match as well, then see Can I force man to do lower case sensitive matching?

  • Did I misunderstand ^ and $ or they are just different here in man page? – Rick Jul 5 at 2:11
  • @Rick they mean the same in any line-based context - for example compare echo 'foo bar' | sed -n '/^bar/p' versus echo 'foo bar' | sed -n '/\bbar/p' – steeldriver Jul 5 at 2:16
0

A GUI alternative is to use this:

man tar.png

Click on the first link and then type Ctrl+F followed by -z, and you are greeted with:

man tar -z.png

Of course using CLI is faster for quick and dirty but for extensive reading I prefer the internet.

  • 1
    Ah I know this one. But sometimes it would be cubersome to open in brower. Thanks anyway. – Rick Jul 5 at 2:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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