【发布时间】:2015-09-16 15:29:04
【问题描述】:
我尝试删除倒数第二行的逗号:
{ "subject" : { "value" : "http://d-nb.info/gnd/1-2", "type" : "uri" }, "predicate" : { "value" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "type" : "uri" }, "object" : { "value" : "http://d-nb.info/standards/elementset/gnd#SeriesOfConferenceOrEvent", "type" : "uri" } }, {
我正在使用这个命令:
<test2.file sed '/^\s*\},$/ { N; s/^\s*\},\n\{/^\s*\}\n\{/ }'
我希望输出应该是这样的:
{ "subject" : { "value" : "http://d-nb.info/gnd/1-2", "type" : "uri" }, "predicate" : { "value" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "type" : "uri" }, "object" : { "value" : "http://d-nb.info/standards/elementset/gnd#SeriesOfConferenceOrEvent", "type" : "uri" } } {
但它返回一个错误。
sed: -e 表达式 #1, char 42: 不匹配 {
有人知道它有什么问题吗?谢谢。
P.S.,这里是文件的结尾:
{ "subject" : { "value" : "http://d-nb.info/gnd/1060867974", "type" : "uri" }, "predicate" : { "value" : "http://d-nb.info/standards/elementset/gnd#preferredNameEntityForThePerson", "type" : "uri" }, "object" : { "value" : "_:genid12768016", "type" : "bnode" } }
【问题讨论】: