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?

1 Answer 1

11

/^-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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .