From 1b25883d2148f0f7f6c4cbfe6caf653a2cbf1280 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Tue, 12 Oct 2021 11:02:28 +1300 Subject: [PATCH] Create netstat.nu --- examples/netstat.nu | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/netstat.nu diff --git a/examples/netstat.nu b/examples/netstat.nu new file mode 100644 index 0000000..596cc94 --- /dev/null +++ b/examples/netstat.nu @@ -0,0 +1,17 @@ +let ns = (netstat | lines | skip 1) + +let first-batch = ($ns | keep until $it =~ Active | str collect (char nl) | from ssv -m 1) +let second-batch = ($ns | + skip until $it =~ Active | + skip 1 | + str collect (char nl) | + str find-replace "\[ \]" "[]" --all | + from ssv -m 1 | + default I-Node "" | + default Path "" | + each {|row| if $row.Type == DGRAM { $row | update Path { get I-Node } | update I-Node { get State } | update State "" } { $row } } +) + +$first-batch + +$second-batch