regex - Windows equivalent to grep -B (before context) and -A (after context)? -
in grep
understand there -b
switch will...
print num lines of leading context before matching lines.
... example might run command like:
cvs log -n -s -w<userid> -d"1 day ago" | grep -b14 "some text" > afile
is there equivalent in windows? i've got is:
cvs log -n -s -w<userid> -d"1 day ago" | find "7492" > output.txt
but pipes text on same line 7492
in output, whereas need of preceding lines usefully interpret information. far can see find
command doesn't have switch equivalent -b
switch of grep
. there way of replicating aspect of grep functionality in windows?
use select-string
's -context
argument. example:
git log | select-string limit -context 5,0
this 5 line before, 0 lines after. example happens hash matches git commit message.
if enter 1 number value of parameter, number determines number of lines captured before , after match. if enter 2 numbers value, first number determines number of lines before match , second number determines number of lines after match.
Comments
Post a Comment