aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-10 15:50:53 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-10 15:53:28 +1200
commitffbe8ea91633b29e3f7ca040d3e148f34de11d10 (patch)
tree20ab8ad25f91e533b313c4e13058fc940ac1b1ea
parentStrip trailing lines (diff)
downloadnwatch-ffbe8ea91633b29e3f7ca040d3e148f34de11d10.tar.gz
nwatch-ffbe8ea91633b29e3f7ca040d3e148f34de11d10.zip
Add some ad-hoc Awk filtering to the output
It may be possible to accomplish some/all of this with Nmap or Ndiff features, but I can't see how just yet.
-rwxr-xr-xnwatch15
1 files changed, 14 insertions, 1 deletions
diff --git a/nwatch b/nwatch
index 32a7afe..c981fbc 100755
--- a/nwatch
+++ b/nwatch
@@ -71,5 +71,18 @@ done
# Write diff to stdout if it exists (not an error if it doesn't)
if [[ -r $diff ]] ; then
- cat -- "$diff"
+ awk '/^[-+]Not shown: / { next }
+/^[-+]/ { diff = 1 }
+NF { lines[++l] = $0 }
+function write() {
+ if (diff) {
+ for (l in lines)
+ print lines[l]
+ print ""
+ }
+ diff = l = 0
+}
+!NF { write() }
+END { write() }
+' -- "$diff"
fi