Created
March 9, 2019 21:11
-
-
Save JimDennis/812280af4afc8f54d03ddf3e9b68a371 to your computer and use it in GitHub Desktop.
This file contains 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
# Take output from iwinfo "$INTERFACE" scan command | |
# ... combine each stanza (record) into a single line and | |
# prefix with hostname | |
# Call with -v h="$HOSTNAME" | |
BEGIN {h=sprintf("%s:\t", h); line=h}; | |
/^[^ ]/ {print line; line=h}; | |
/^ / {line=sprintf("%s %s", line, $0)}; | |
END {print line} | |
# Explanation: | |
## mini-state machine parser: prefix set by -v command line arg; then formatted; | |
## any line starting with non-space dumps previous state and starts new state with just prefix | |
## any other line (starts with a space) adds to current (line) state | |
## dump final state (line) at END | |
# "extra" semicolons on line endings allow cut-n-paste direct to command line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment