我有以下格式的 json 文件:
[
{
"organization": "ABC",
"type": "School",
"contact": "Joe Schmo",
"contact_title": "Principal",
"mailing_address": "123 Main Street, Anytown, MA",
"phone": "214-555-5430",
"fax": "214-555-5444"
},
{
"organization": "XYZ",
"type": "School",
"contact": "John Doe",
"contact_title": "Asst Principal",
"mailing_address": "123 Main Street, Anycity, TX",
"phone": "512-555-5430",
"fax": "512-555-5444"
},
.
.
.
.
]
我想复制以开头的行,然后在替换为and"organization"
后将其添加回文件两次。我也想保留原线。我想要的输出是:"organization"
"company"
"long name"
[
{
"organization": "ABC",
"company": "ABC",
"long name": "ABC",
"type": "School",
"contact": "Joe Schmo",
"contact_title": "Principal",
"mailing_address": "123 Main Street, Anytown, MA",
"phone": "214-555-5430",
"fax": "214-555-5444"
},
{
"organization": "XYZ",
"company": "XYZ",
"name": "XYZ",
"type": "School",
"contact": "John Doe",
"contact_title": "Asst Principal",
"mailing_address": "123 Main Street, Anycity, TX",
"phone": "512-555-5430",
"fax": "512-555-5444"
},
.
.
.
.
]
awk
或sed
首选解决方案。