script1:
#!/bin/bash #Date:2016-11-16 #Author:eivll0m awk -F" " -vq='"' '{ a[$1]=a[$1]?a[$1]" "$2" "$3" "$4:$2" "$3" "$4 }END{ for(i in a){ printf i" [";l=split(a[i],b," ");
for(j=1;j<=l;j+=3){ printf "{h_name"":"q b[j] q",";
printf "level"":"q b[j+1] q",";
printf "addres"":"q b[j+2] q"}," } print "]" } }' yy.txt|sed 's/,]$/]/' >>yy_json.txt
script2:
#!/bin/bash #Date:2016-11-17 #Author:eivll0m awk -F" " -vq='"' ' function json(x,y){printf("%s:%s,",q x q, q y q)} function json2(x,y){printf("%s:%s",q x q, q y q)} function json3(x,y){printf("%s:%s",q x q, y)} { printf "{";
json("id",$2); printf q"essential_info"q":{"; json("name",$1); json("introduction",$3); json("medical_insurance",$4); json("alias",$5);
json("position",$6); json("infectivity",$7); json("route_of_transmission",$8); json2("multiple_population",$9);
printf "},"; printf q"symptom"q":{"; json("typical",$10); json2("content",$11);
printf "},"; json("pathogeny",$12);
json("prevent",$13); printf q"inspect"q":{"; json("item",$14); json2("content",$15);
printf "},"; json("differentiate",$16); printf q"treat"q":{"; json("mode",$17); json2("content",$18);
printf "},"; json("nurse",$19); json("complication",$20); json3("hospital",$21); print "}" }' jibin.TXT >jibin.json