How to parse white-space-separated table with augeas?

113 views Asked by At

Suppose I have fstab-like 2-dimensional white-space separated table (in my case it is /etc/lxc/lxc-usernet), with the following typical contents:

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

How to edit it with augeas? I don't need to address the fields by name, they can be addressed by index if that helps.

1

There are 1 answers

0
raphink On

You will need to write a lens for this. The best option is to copy the Fstab module and adjust the fields.

You could also do some simpler, along the lines of (adapt field labels):

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)*