【发布时间】:2017-02-07 04:16:09
【问题描述】:
这是我的文件
$ cat testjson2
[alot of text]
我希望得到以下结果:({ "aaData": 附加在文件开头 } 附加在文件末尾)
{ "aaData": [alot of text] }
到目前为止我得到了什么:
这会在文件的开头追加
$ sed '1s/./{ "aaData": &/' testjson2
{ "aaData": [alot of text] }
这会在文件末尾追加
$ echo } >> testjson2
$ cat testjson2
[alot of text]
}
如何组合它们?也许只是使用 sed 还是应该只使用这种组合来获得我想要的? 只是看看在这里使用 sed awk 或 bash。
【问题讨论】: