Re: Find a string with a specified number os lines
2006-11-03, 11:43(-06), Ed Morton:
[...]
>>>$ grep -L 3 file orange
>>>
>>>banana
>>>orange
>>>eggs
>>>
>>>Obviously the -L parameter doesn't exist in grep.
>>
>> [...]
>>
>> awk 'NR == 3 && /orange/' < file
>>
>> sed '3!d;/orange/!d' < file
>>
>
> I THINK what the OP wanted was to print 3 lines of context around a
> pattern, not the line that pattern is on if it's on a specific line number.
Indeed. I should get back to bed asap...
> For the OP: get GNU grep and check the man page, what you seem to want
> is already present.
[...]
Yes, and search this group archives where the question is often
asked.
--
Stéphane
|