首页 新闻 会员 周边

shell sed 命令如何实现在查找匹配到的行之前插入内容

0
悬赏园豆:30 [已解决问题] 解决于 2020-04-05 12:03

请问如何用在 linux 中通过 sed 命令实现下面的需求?

在下面的内容之前

= Gon::Base.render_data(nonce: content_security_policy_nonce)

插入下面的内容

%style{type: "text/css"}
  code { color: #c0341d; background-color: #fbe5e1; }
dudu的主页 dudu | 高人七级 | 园豆:30994
提问于:2020-04-05 11:52
< >
分享
最佳答案
0

搞定了,强大的 sed

sed -i '/^\s*= Gon::Base.render_data.*/i \ \ %style{type: "text/css"}\n    code { color: #c0341d; background-color: #fbe5e1; }\n' _head.html.haml
dudu | 高人七级 |园豆:30994 | 2020-04-05 12:02
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册