On 04/20/2017 11:51 AM, Assaf Gordon wrote:
> If I may suggest the following sed program:
>
> $ cat file
> a
> b
> c
> bla1
> bla2
> UGLY
> bla3
> bla4
> e
> f
> g
>
> $ sed -n ':x 1,2{N;bx} ; /UGLY/{ N;N;z;bx }; /./P;N;D' file
Works as long as lines 1 and 2 do not contain UGLY.
Yes those are brilliant uses of sed. However for now
‘-v’
‘--invert-match’
Invert the sense of matching, to select non-matching lines. (‘-v’
is specified by POSIX.)
perhaps should mention that "-v is processed before -C, -A, and -B, not after."
Hello,
On Thu, Apr 20, 2017 at 11:26:47AM -0500, Eric Blake wrote:
On 04/20/2017 10:37 AM, 積丹尼 Dan Jacobson wrote:
I want to do
$ cat file|some_program
but I must must exclude the UGLY line and its two neighbors.
OK I have found the UGLY line, and its two neighbors
$ grep -C 2 UGLY file
bla
On 04/20/2017 11:38 AM, 積丹尼 Dan Jacobson wrote:
> Yes, if somebody ever adds this option perhaps call it --compliment.
Except that you mean --complement (you are not praising the lines, but
making an opposite selection of lines).
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Yes, if somebody ever adds this option perhaps call it --compliment.
On 04/20/2017 10:37 AM, 積丹尼 Dan Jacobson wrote:
> I want to do
> $ cat file|some_program
> but I must must exclude the UGLY line and its two neighbors.
>
> OK I have found the UGLY line, and its two neighbors
> $ grep -C 2 UGLY file
> bla
> bla
> UGLY
> bla
> bla
>
> but I have no way to exclude
I want to do
$ cat file|some_program
but I must must exclude the UGLY line and its two neighbors.
OK I have found the UGLY line, and its two neighbors
$ grep -C 2 UGLY file
bla
bla
UGLY
bla
bla
but I have no way to exclude them before piping to some_program.
On 04/20/2017 10:14 AM, 積丹尼 Dan Jacobson wrote:
> Mmmm, OK, but grep still needs an additional future option to print just
> the missing set...
What output are you wanting? If all you want is the non-matching lines,
don't ask for context (since the context will include matching lines).
If you
Mmmm, OK, but grep still needs an additional future option to print just
the missing set...
tag 26576 notabug
thanks
On 04/20/2017 09:39 AM, 積丹尼 Dan Jacobson wrote:
> You know if this only gets five lines,
> grep -C 2ZZZ 1.vcf|wc - 1.vcf
> 5 5 197 -
>16861731 83630 1.vcf
> then this
> grep -C 2 -v ZZZ 1.vcf|wc - 1.vcf
>16861731
You know if this only gets five lines,
grep -C 2ZZZ 1.vcf|wc - 1.vcf
5 5 197 -
16861731 83630 1.vcf
then this
grep -C 2 -v ZZZ 1.vcf|wc - 1.vcf
16861731 83630 -
16861731 83630 1.vcf
should get all EXCEPT five lines.
11 matches
Mail list logo