Last active
July 9, 2024 16:15
-
-
Save alq666/3c255e26799a35fb01733eb86ea22001 to your computer and use it in GitHub Desktop.
Parse /proc/net/netstat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/^TcpExt:/ { | |
for (i=2; i <= NF; i++) { | |
if (match($i, /[[:digit:]]+/)) { | |
values[i] = $i | |
} else { | |
keys[i] = $i | |
} | |
} | |
} | |
END { for (i=1; i <= length(keys); i++) { print keys[i], values[i] }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the first regex should be
/^TcpExt:/
or else theMPTcpExt
segment will break the parsing of the starting fields