#!/bin/awk -f ############################# # clean data and filter some to rediect to new file # Author: Liao # modify time: 2021/12/15 17:05 (+8:00) ############################# BEGIN{ # system("echo '\n\n\n----------' >> "awk_run_log_path" && date '+%x %X' >> "awk_run_log_path) dp_recv_from_device = @/ dp rept_type:[[:digit:]]+, data:{/ dp_is_condition = @/dp [[:digit:]]+ match/ dp_not_condition = @/no [[:digit:]]+ match/ pattern = @/([[:digit:]]+-[[:digit:]]+ ([[:digit:]]+:){3}[[:digit:]]+)/ connection_check_ok = @ # Get form OS } !a++{ } $0~dp_recv_from_device{ matchRet(/([0-9]{1,2}-[0-9]{1,2} ([0-9]{1,2}:){3}[0-9]{1,3})/); substr($0,RSTART,RLENGTH) match($0,"^\\[([[:digit:]]+-[[:digit:]]+ ([[:digit:]]+:){3}[[:digit:]]+).*? dp .*?, data:(.*)$",d) print d[1],d[3] echo '[12-09 19:03:03:863 TUYA Debug][smart_frame.c:2110] dp rept_type:0, data:{"1":true}' } $0~dp_is_condition{ } $0~connection_check_ok{ } END{ } function matchRet(reg ,RSTART,RLENGTH){ match($0,reg); return substr($0,RSTART,RLENGTH) }