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 -
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 -
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 “-”.
-f
option from grep
takes a filename as parameter that contains patterns.
– schily
Sep 07 '18 at 15:45