#!/bin/bash
format(){
usedifs="$IFS"
IFS=$'\n';[ $# -eq 0 ] && { echo "not files need format." ;exit 1; }
for((i=1;i<=$#;i++));do files=(${files[@]} ${!i});done
log1(){
cat ${files[@]}|sed '/^[a-z]\+:/!d;s/[ \t]\+//g'|xargs -n3|\
awk 'BEGIN{FS="[ :]"}
{ x=$1;y=$3;z=$5
a[$2]+=$4
b[$2]=b[$2]?b[$2]","$NF:$NF
}END{
for(i in a){
split(b[i],t,",");
for(j in t)p["\""t[j]"\""]
for(k in p)v=v?v","k:k
print "{\""x"\":\""i"\",\""y"\":\""a[i]"\",\""z"\&
将文本转换成json格式
最新推荐文章于 2024-05-11 00:27:18 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)