1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00

Create netstat.nu

This commit is contained in:
JT 2021-10-12 11:02:28 +13:00 committed by GitHub
parent c0df9802c0
commit 1b25883d21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

17
examples/netstat.nu Normal file
View file

@ -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