|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
How could I find a string with a specified number os lines ?
Like this $ cat file apple banana orange eggs strawberry $ grep -L 3 file orange banana orange eggs Obviously the -L parameter doesn't exist in grep. Regards |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
2006-11-3, 08:09(-08), apogeusistemas@gmail.com:
> How could I find a string with a specified number os lines ? > > Like this > > $ cat file > > apple > banana > orange > eggs > strawberry > > $ 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 -- Stéphane |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Stephane CHAZELAS wrote:
> 2006-11-3, 08:09(-08), apogeusistemas@gmail.com: > >>How could I find a string with a specified number os lines ? >> >>Like this >> >>$ cat file >> >>apple >>banana >>orange >>eggs >>strawberry >> >>$ 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. For the OP: get GNU grep and check the man page, what you seem to want is already present. Ed. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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 |
|
![]() |
| Outils de la discussion | |
|
|