Grepping iwinfo

Just assign the current date to a variable in awk and use this variable in the printf output, e.g.:

iwinfo wlan0 assoclist | awk -v date="$(date "+%d.%m.%Y %H:%M:%S")" '/^[[:alnum:]]/{printf "%s ::: %s",date,$0;for(line=1;line<=3;line++){getline;printf(line==3)?$0"\n":$0}}'

Output:

01.01.2020 19:53:25 ::: AA:BB:CC:DD:EE:FF  -69 dBm / unknown (SNR -69)  0 ms ago	RX: 108.0 MBit/s                               19581 Pkts.	TX: 121.5 MBit/s                               39076 Pkts.	expected throughput: unknown

Edit: Happy New Year! :slightly_smiling_face:

1 Like