Invalid max count in grep function

Some Java Guy picture Some Java Guy · Mar 2, 2011 · Viewed 26.9k times · Source

If I do a find . -mmin -1 I get 'myfile' which was modified in last one minute.

But when I want to search a particular string in that file by doing

grep 'myString' myfile -mmin -1 

I get the error invalid max count

I also tried

find . -name "myfile" -exec grep 'myString' myfile -mmin -5

I get the error find: missing argument to -exec

So my question is How do I grep or cat only the changes within a file which happened in last 5 mins. Now that I know the file name which was modified during that period.

Suggestions? Thanks in adv.

Answer

Johan Ur Riise picture Johan Ur Riise · Nov 18, 2011

grep something *

Error:

grep: invalid max count

Verify that you have a file with a leading dash in the name in the current directory. The file name might be taken for an option.

For example:

grep something // okay

touch -- -mmin

**grep something **

grep: invalid max count

Workaround:

**grep -- something **

From man getopt:

Each parameter after a -- parameter is always interpreted as a non-option parameter.