Quote:
Originally Posted by
countryStyle
Yeah....I am a wanna be teacher and fulfill my fantasies by quizzing people on the internet. Go get a life....you are being difficult.
If you'd posted your data you could have had an answer an hour ago...
Quote:
Maybe you answered my question....but you sound generally uninformed
I'll ignore the personal slur and explain a little more.
grep considers no logic but patterns when matching lines. It doesn't remember anything about previous lines and has no expression to carry information from previous lines across to next ones. The awk language is much better suited, since it deals with lines/patterns
and has variables plus logical expressions. (I think sed does too in a fashion, but its expression syntax is rather convoluted. awk gives you straightforward variables with names, and straightforward expressions with if/else.)
Quote:
because you are being difficult:
I'm only asking you for your data. I'm not even the first one.
If you really want I'll give you a ridiculous solution like
grep pattern file | tail -n +5 | head -n 1 to get match 4 which is of course a very silly solution and might not work in Solaris. A less silly solution would be
nawk '/pattern/ {} NR==2' but you asked for grep, this may not suit your needs, and there may be even more efficient ways to deal with the data depending on what it actually is and what you're trying to do.