Forum: CFEngine Help Subject: delete_lines and select region Author: jbdenis Link to topic: https://cfengine.com/forum/read.php?3,26551,26551#msg-26551
Hello everybody, I'm using CFEngine Core 3.3.4. Basically I want to remove everything after a specific line in a file. For example : # cat /tmp/myfile some garbage #### CFENGINE ANCHOR i want to remove this line this one too and this one ! Here is my cfengine file : body common control { bundlesequence => { example }; inputs => { "cfengine_stdlib.cf" }; } bundle agent example { files: "/tmp/myfile" edit_line => editfile, create => "true"; } bundle edit_line editfile { vars: "sdelim" string => "#### CFENGINE ANCHOR"; delete_lines: ".*" select_region => from_line("$(sdelim)"); # I want to insert my anchor line if it is not present the first time insert_lines: "$(sdelim)"; } body select_region from_line(start) { select_start => "$(start)"; include_start_delimiter => "false"; } Here is the ouput : # cf-agent -KI -f ./editfile.cf !! The promised line deletion (.*) could not select an edit region in /tmp/myfile (but the delimiters were expected in the file) !! The promised line deletion (.*) could not select an edit region in /tmp/myfile (but the delimiters were expected in the file) -> Edited file /tmp/myfile And the the file : some garbage #### CFENGINE ANCHOR That's what I want, but what about the warnings in the cf-agent run ? If this is a normal behaviour, how can I not print it ? If I run it again, it's still here (plus one) : # cf-agent -KI -f ./editfile.cf !! The promised line deletion (.*) could not select an edit region in /tmp/myfile (but the delimiters were expected in the file) !! The promised line deletion (.*) could not select an edit region in /tmp/myfile (but the delimiters were expected in the file) !! The promised line deletion (.*) could not select an edit region in /tmp/myfile (but the delimiters were expected in the file) Any suggestions ? _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine