Invalid maximum quantity in grep function

If I do find . -mmin -1 find . -mmin -1 , I get "myfile", which was changed in the last minute.

But when I want to find a specific line in this file by doing

 grep 'myString' myfile -mmin -1 

I get an invalid max count error message

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

+4
source share
2 answers

Grep has no mmin argument, as far as I can see. It has the -m argument with the number parameter. grep 'myString' myfile -m3 will stop after three lines containing myString. Thus, an error message means that the "min" in -mmin not a valid maximum quantity.

+2
source

grep something *

Error:

grep: invalid maximum quantity

Make sure you have a file with a leading dash in the name in the current directory. The file name can be used for the parameter.

For instance:

 grep something // okay touch -- -mmin 

** grep something **

grep: invalid maximum quantity

Workaround:

** grep - something **

From man getopt :

Each parameter after the parameter -- always interpreted as an optional parameter.

+4
source

Source: https://habr.com/ru/post/1341939/


All Articles