In Mac OS X, I see that -m is not a supported option of grep. It is supported in cygwin. Is this a cygwin specific feature or does Mac OS X just not support it? Is there anything else I can use in its stead?
Stop reading a file after NUM matching lines. If the input is standard input from a regular file, and NUM matching lines are output, grep ensures that the standard input is positioned to just after the last matching line before exiting, regardless of the presence of trailing context lines. This enables a calling process to resume a search. When grep stops after NUM matching lines, it outputs any trailing context lines. When the -c or --count option is also used, grep does not output a count greater than NUM. When the -v or --invert-match option is also used, grep stops after outputting NUM non-matching lines.
Stop reading a file after NUM matching lines. If the input is standard input from a regular file, and NUM matching lines are output, grep ensures that the standard input is positioned to just after the last matching line before exiting, regardless of the presence of trailing context lines. This enables a calling process to resume a search. When grep stops after NUM matching lines, it outputs any trailing context lines. When the -c or --count option is also used, grep does not output a count greater than NUM. When the -v or --invert-match option is also used, grep stops after outputting NUM non-matching lines.
Haven't used grep enough to comment on it.
I were half as knowledgable as you I'd be a member of Mensa.
Fahlman: Nice of you to say That was just copied from the man pages for grep though. There are many people on these forums more knowledgeable than me. Like Kickaha.
Comments
Originally posted by Kickaha
Well what is it supposed to *do*?
Looking at my cygwin install:
-m NUM, --max-count=NUM
Stop reading a file after NUM matching lines. If the input is standard input from a regular file, and NUM matching lines are output, grep ensures that the standard input is positioned to just after the last matching line before exiting, regardless of the presence of trailing context lines. This enables a calling process to resume a search. When grep stops after NUM matching lines, it outputs any trailing context lines. When the -c or --count option is also used, grep does not output a count greater than NUM. When the -v or --invert-match option is also used, grep stops after outputting NUM non-matching lines.
Haven't used grep enough to comment on it.
I can't use
grep -m 1 <string> <file>
but I can use
grep <string> <file> | head -n 1
Originally posted by MCQ
Looking at my cygwin install:
-m NUM, --max-count=NUM
Stop reading a file after NUM matching lines. If the input is standard input from a regular file, and NUM matching lines are output, grep ensures that the standard input is positioned to just after the last matching line before exiting, regardless of the presence of trailing context lines. This enables a calling process to resume a search. When grep stops after NUM matching lines, it outputs any trailing context lines. When the -c or --count option is also used, grep does not output a count greater than NUM. When the -v or --invert-match option is also used, grep stops after outputting NUM non-matching lines.
Haven't used grep enough to comment on it.
I were half as knowledgable as you I'd be a member of Mensa.
Originally posted by rogue master
I found a solution to my problem.
I can't use
grep -m 1 <string> <file>
but I can use
grep <string> <file> | head -n 1
Yeah, that would work.
Fahlman: Nice of you to say That was just copied from the man pages for grep though. There are many people on these forums more knowledgeable than me. Like Kickaha.