diff --git a/modules/examples/netstat.nu b/modules/examples/netstat.nu index 596cc9412..e4d964bfb 100644 --- a/modules/examples/netstat.nu +++ b/modules/examples/netstat.nu @@ -1,17 +1,25 @@ 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 | +let first_batch = ($ns | take until {|it| $it =~ Active } | str join (char nl) | from ssv -m 1) +let second_batch = ($ns | + skip until {|it| $it =~ Active } | skip 1 | - str collect (char nl) | - str find-replace "\[ \]" "[]" --all | + str join (char nl) | + str 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 } } -) + default Path "" + | each {|row| if $row.Type == DGRAM { + $row | update Path { get I-Node } | update I-Node { get State } | update State "" + } else { + $row + } + } +) + +print $first_batch +print $second_batch + + -$first-batch -$second-batch