【问题标题】:How to parse white-space-separated table with augeas?如何用 augeas 解析空格分隔的表?
【发布时间】:2014-12-14 10:07:37
【问题描述】:

假设我有fstab-like 二维空格分隔表(在我的例子中是/etc/lxc/lxc-usernet),具有以下典型内容:

# USERNAME TYPE BRIDGE COUNT
adam veth lxcbr0 10
tempuser veth lxcbr1 5

如何用 augeas 编辑它?我不需要按名称对字段进行寻址,如果有帮助,可以通过索引对其进行寻址。

【问题讨论】:

    标签: augeas


    【解决方案1】:

    您需要为此编写一个镜头。最好的选择是复制Fstab module 并调整字段。

    您还可以按照(调整字段标签)的方式做一些更简单的事情:

    module LXC_usernet =
    
    let entry = [ seq "entry"
                . [ label "name" . store Rx.word ] . Sep.space
                . [ label "type" . store Rx.word ] . Sep.space
                . [ label "dev" . store Rx.word ] . Sep.space
                . [ label "value" . store Rx.word ] . Util.eol ]
    
    let lns = (Util.empty | Util.comment | entry)*
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-23
      • 2020-08-28
      • 1970-01-01
      • 2014-01-09
      • 2017-01-25
      • 1970-01-01
      • 2012-04-25
      • 1970-01-01
      相关资源
      最近更新 更多