Thanks for sharing, Sjoerd.  How do you use this?

I can imagine a use for appending a line if it is not already in a file,
but what is the scenario where you want to append a line if some
other regex is not in a file?

Thanks very much,
Aleksey


On Thu, May 26, 2011 at 7:54 AM, Sjoerd Oostdijck <sjoer...@ripe.net> wrote:
> I wracked my brain over this one for some reason, and it turned out to
> be so simple... I did find a few old threads asking for this, so I
> though I'd share:
>
>
> # Appends the supplied line if the regex supplied did not
> # match an already existing line.
> #
> # files:
> #   "myfile.txt"
> #     edit_line => append_line_if_no_match(".*foo.*","foobar bas");
> #
> bundle edit_line append_line_if_no_match(regex,line)
> {
> classes:
>  "regex_matched"
>    expression =>regline("^$(regex)$","$(edit.filename)");
>
> insert_lines:
>  !regex_matched::
>    "$(line)"
>      comment => "Insert line if regex did not match";
> }
>
> --
> Sjoerd Oostdijck                  RIPE Network Coordination Centre
> RIPE NCC, IT Department                  Singel 258, Amsterdam, NL
> http://www.ripe.net                                +31 20 535 4444
>
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to