1

When I try to execute :

$ man find | grep "-mtime"

I get this message back :

grep: invalid max count

I wonder how to search with the -

  • 2
    try with: man find | grep "-mtime" – Rakesh.N Sep 07 '18 at 14:18
  • 2
    Related questions are https://unix.stackexchange.com/questions/1519/ , https://unix.stackexchange.com/questions/87355/ , https://unix.stackexchange.com/questions/3877/ , and https://unix.stackexchange.com/questions/364922/ . – JdeBP Sep 07 '18 at 14:20
  • if you are often extracting option description from man pages, I would suggest https://explainshell.com/explain?cmd=find+-mtime or a bash script I wrote(https://github.com/learnbyexample/command_help) for use from cli – Sundeep Sep 07 '18 at 15:41

1 Answers1

2

As @Fólkvangr commented, the problem is that your pattern starts with a - character.

To avoid that grep will try to use the pattern as a parameter, you have to use the -e parameter before the pattern.

$ man find | grep -e "-mtime"

From man grep

-e PATTERN, --regexp=PATTERN

Use PATTERN as the pattern. If this option is used multiple times or is combined with the -f (--file) option, search for all patterns given. This option can be used to protect a pattern beginning with “-”.

andcoz
  • 17,130