[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
inverting --before-context/--after-context with -v.
From: |
Matt Rice |
Subject: |
inverting --before-context/--after-context with -v. |
Date: |
Sun, 18 Sep 2011 00:38:49 -0700 |
I was a little confused by the behaviour of -v with -B and -A,
how it works is like:
for i in a b a c a c; do echo $i; done | grep -v -B1 "c"
a
b
a
c <-- before match
a <-- match
what I was hoping it would do:
a
b
not output each "c", and also not outputting the line before it.
there is possibly some way to do it with git/diff
committing the initial output/the grep -v -B1 "c" output, and an empty file,
then merging diff from committing the empty file with the original one...
(that's what I did... but not sure if some output will have a conflict)
theres probably a better way to do it with sed, but if i could figure
it out I probably wuoldn't remember it anyways.
would this be something you guys would consider adding to grep via
some new option?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- inverting --before-context/--after-context with -v.,
Matt Rice <=