<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 01/04/2016 03:16 PM, allonon wrote:<br>
</div>
<blockquote
cite="mid:CAAXkdhLo+WE6m=aZ6U0ufO+xS4drb0dCMESabGV7VihAreeTgw@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<div dir="ltr">I wanted to start a different topic as mine is not
about flash or bootflash.
<div><br>
</div>
<div>I have a similar issue with nexus output and want to
prevent diff emails but I want the data in the the saved
config. One of switches will constantly adjust output watts
by a few points. </div>
<div><br>
</div>
<div>
<div><br>
</div>
<div> !Env: ------- ------------------- ----------
---------- ---------- --------------</div>
<div>- !Env: 1 N9K-PAC-650W-B 67 W
649 W Ok</div>
<div>- !Env: 2 N9K-PAC-650W-B 71 W
649 W Ok</div>
<div>+ !Env: 1 N9K-PAC-650W-B 68 W
649 W Ok</div>
<div>+ !Env: 2 N9K-PAC-650W-B 70 W
649 W Ok</div>
<div><br>
</div>
<div><br>
</div>
<div>My scripting-fu is non-existent and am trying to learn
this. </div>
<div><br>
</div>
<div>I figure I have 3 options. </div>
<div> Just have Rancid ignore the line. (not preferred as
I want to see the PS as OK or not)</div>
</div>
<div> Filter email output.</div>
<div> Filter the actual diff. (can the diff actually handle
advanced parsing? Everything I see shows how to ignore line
based on simple match)</div>
<div><br>
</div>
<div>I found this snippet from another thread on how to filter
email output but I'm getting lost on what it is doing after
the first grep</div>
<div><font face="Verdana,Arial,Helvetica" color="black" size="2"><font
face="Verdana,Arial,Helvetica" color="black" size="2"><font
color="#660066">> DIFF=`cat $TMP.diff | grep -v
"^===" | grep -v "^diff " | grep -v <br>
> "^Index: " | grep -v "^retrieving revision" | grep
-v "^$"` <br>
> if [ -n "$DIFF" ]; then <br>
> ...email stuff here... <br>
> fi </font></font></font><br>
</div>
<div><br>
</div>
<div>How do I best adjust this so that it greps for the ENV or
N9K-PAC line, and ignore (not send diff email) it if the Ok is
there.</div>
<div><br>
</div>
<div>Thanks</div>
<br>
</div>
</blockquote>
The multiple greps in that example are for different commands they
want to match and exclude. You can do something like this:<br>
<br>
DIFF=`cat $TMP.diff | grep -Ev "[ +-] \!Env: [0-9]"`<br>
<br>
You can test if your regex is working by making a fake diff and
seeing if the grep matches :<br>
[rdrake@test ~]$ cat test.in | grep -E "[ +-] \!Env: [0-9]"<br>
- !Env: 1 N9K-PAC-650W-B 67 W
649 W Ok<br>
- !Env: 2 N9K-PAC-650W-B 71 W
649 W Ok<br>
+ !Env: 1 N9K-PAC-650W-B 68 W
649 W Ok<br>
+ !Env: 2 N9K-PAC-650W-B 70 W
649 W Ok<br>
<br>
[rdrake@test ~]$ cat test.in | grep -Ev "[ +-] \!Env: [0-9]"<br>
!Env: ------- ------------------- ---------- ----------
---------- --------------<br>
<br>
(if you want to get rid of this line too you can use this)<br>
<br>
[rdrake@test ~]$ cat test.in | grep -Ev "[ +-] \!Env: [0-9-]"<br>
[rdrake@test ~]$<br>
<br>
</body>
</html>