【发布时间】:2017-12-16 22:20:32
【问题描述】:
在 Unix 上,不向操作系统添加任何内容(即仅使用 grep、awk、sed、cut 等),如何将以下输入拆分为从每个“codeView”行开始的多个文件(例如“_temp1.txt”、“_temp2.txt”等)? 请注意,该行可能以多个空格开头。
如果输入来自 API 而不是现有文件怎么办?
. . .
"events" : [ {
"id" : "123456",
"important" : true,
"codeView" : {
"lines" : [ {
"fragments" : [ {
"type" : "NORMAL_CODE",
"value" : "str = wrapper.getParameter("
}, {
"type" : "NORMAL_CODE",
"value" : ")"
} ],
"text" : "str = wrapper.getParameter("motif")"
} ],
"nested" : false
},
"probableStartLocationView" : {
"lines" : [ {
"fragments" : [ {
"type" : "STACKTRACE_LINE",
"value" : "<init>() @ JSONInputData.java:12"
} ],
"text" : "<init>() @ JSONInputData.java:92"
} ],
"nested" : false
},
"dataView" : {
"lines" : [ {
"fragments" : [ {
"type" : "TAINT_VALUE",
"value" : "CP"
} ],
"text" : "{{#taint}}CP{{/taint}}"
} ],
"nested" : false
},
"collapsedEvents" : [ ],
"dupes" : 0
}, {
"id" : "28861,28862",
"important" : false,
"type" : "P2O",
"description" : "String Operations Occurred",
"extraDetails" : null,
"codeView" : {
"lines" : [ {
"fragments" : [ {
"type" : "TEXT",
"value" : "Over the following lines of code, blah blah."
} ],
"text" : "Over the following lines of code, blah blah."
} ],
"nested" : false
},
"probableStartLocationView" : {
"lines" : [ {
"fragments" : [ {
"type" : "STACKTRACE_LINE",
"value" : "remplaceString() @ O_UtilCaractere.java:234"
} ],
"text" : "remplaceString() @ O_UtilCaractere.java:234"
}, {
"fragments" : [ {
"type" : "STACKTRACE_LINE",
"value" : "replaceString() @ O_UtilCaractere.java:333"
} ],
"text" : "replaceString() @ O_UtilCaractere.java:333"
}, {
"fragments" : [ {
"type" : "STACKTRACE_LINE",
"value" : "creerIncidentPaie() @ Incidents.java:444"
} ],
"text" : "creerIncidentPaie() @ Incidents.java:219"
}, {
"fragments" : [ {
"type" : "STACKTRACE_LINE",
"value" : "repliquerAbsenceIncident() @ Incidents.java:876"
} ],
"text" : "repliquerAbsenceIncident() @ IncidentsPaieMgr.java:882"
} ],
"nested" : false
},
"dataView" : {
"lines" : [ {
"fragments" : [ {
"type" : "TEXT",
"value" : "insert into TGE_INCIDENT...4&apos;, &apos;YYYYMMDD&apos;), &apos;A&apos;, &apos;"
}, {
"type" : "TAINT_VALUE",
"value" : "CP"
}, {
"type" : "TEXT",
"value" : "&apos;, &apos;&apos;, null, &apos;T&apos;, &apos;ADPTVT&apos;, to_date(&apos;2013012214..."
} ],
"text" : "insert into TGE_INCIDENT...4&apos;, &apos;YYYYMMDD&apos;), &apos;A&apos;, &apos;{{#taint}}CP{{/taint}}&apos;, &apos;&apos;, null, &apos;T&apos;, &apos;ADPTVT&apos;, to_date(&apos;2017062214..."
} ],
"nested" : false
}
. . .
【问题讨论】: