5

When navigating through Linux man pages, sometimes you need to query the meaning of flags like -p or -al in the man pages.

The default text reader for man pages is less and I'm trying to use the / search to find the first occurrence from the commons flag list definitions using:

/^-p

But Pattern not found happen and not works.

This trick works when working in vim, but not applicable in less when reading the man pages.

Is there a way to accomplish this requirement?

Seamus
  • 2,522
  • 1
  • 16
  • 31
Silver137
  • 329
  • 1
  • 8

1 Answers1

10

/^-p means there are no characters before -p. But if you look at the man pages, you will see there are some blank characters preceding these flags.

The search pattern should be /^\s+-p

where:

  • ^ matches the beginning of the line
  • \s+ matches one or more occurrences of whitespace characters

Edit: While the search pattern above is ideal, it is not very practical when searching. An easy way to find such sections in man pages is to use / -p. Slash, followed by 2 spaces and the option your are searching for.

GMaster
  • 5,992
  • 3
  • 28
  • 32