免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6938 | 回复: 0
打印 上一主题 下一主题

[文本处理] 如何使用shell脚本在文本中的特定位置添加内容? [复制链接]

论坛徽章:
5
程序设计版块每日发帖之星
日期:2016-04-15 06:20:00每日论坛发贴之星
日期:2016-04-15 06:20:0015-16赛季CBA联赛之八一
日期:2016-07-08 09:20:28操作系统版块每日发帖之星
日期:2016-08-03 06:20:002016科比退役纪念章
日期:2016-10-30 13:59:12
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2021-05-03 23:01 |显示全部楼层 |倒序浏览
在ubuntu 18.04系统中,我查看这个命令:
cat /usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml
最后一部分的内容如下所示:


    <key name='notify-on-connect' type='b'>
      <summary>Notify on connect</summary>
      <description>
        If true, show a notification when a user connects to the system.
      </description>
      <default>true</default>
    </key>
  </schema>
</schemalist>




现在我想在倒数第三行开始插入一段内容,插入后如下所示:

    <key name='notify-on-connect' type='b'>
      <summary>Notify on connect</summary>
      <description>
        If true, show a notification when a user connects to the system.
      </description>
      <default>true</default>
    </key>

    <key name=’enabled’ type=’b’>
      <summary>Enable remote access to the desktop</summary>
      <description>
        If true, allows remote access to the desktop via the RFB
        protocol. Users on remote machines may then connect to the
        desktop using a VNC viewer.
      </description>
      <default>false</default>
    </key>

  </schema>
</schemalist>



上面红色是我插入的内容,请问我如果要实现这种插入,shell脚本应该如何来写?在指定的位置插入一段内容,并且这一段内容,每一行前面的空格也是固定的,
像上图中红框中的第一行  <key name=’enabled’ type=’b’>,前面有4个空格。而第二行 <summary>Enable remote access to the desktop</summary>,前面有6个空格。我应该如何写脚本达到这种效果。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP