What's a working example of modifying /etc/export using bash?Example:I want to ensure the following rule is present and valid:/export/home 2400:123::/32(rw,no_root_squash)And it should:Add only if it doesn't exist already (in any form)If it partly exists, it shold update existing entry (e.g options update)Possible syntaxes in existing file:Multiple whitespaces, and different options/export/home                    2400:123::/32(rw,no_root_squash,no_subtree_check)Multiple allow on same line/export/home 2400:123::/32(rw,no_root_squash,no_subtree_check) 2400:321::/32(rw,no_root_squash,no_subtree_check)In addition to combinations of the above.Initially I wanted to use augeas for this, but there's a bug with IPv6 adresses in the /etc/exports file.The /etc/exports file should allow independent modifying witout breaking the script (which should ensure only the rule in question is correct and valid, and leave the rest of the rules alone)
Ensure /etc/export contains rule using bash
bash;sed;regular expression;puppet
If you can't use Augeas and Puppet, here's what I would do:if grep -qF '^/export/home' /etc/exports;then    sed -i \    's@^/export/home.*$@/export/home 2400:123::/32(rw,no_root_squash)@'\    /etc/exportselse    echo '/export/home 2400:123::/32(rw,no_root_squash)' >> /etc/exportsfiCareful, though: this assumes that any rule for exporting /export/home is fair game for being replaced by your given definition.