Forum: Cfengine Help Subject: Re: Edit region of file - remove existing content Author: kholloway Link to topic: https://cfengine.com/forum/read.php?3,18633,18637#msg-18637
Just tried with this code and a different start/ending delim. Outcome is identical, everything between the selected region gets deleted and replaced but everything past the end delim in the file gets deleted to EOF. It's as if the end of the select region is simply being ignored. bundle agent test { files: testhost:: "/tmp/test_dest.txt" comment => "Test, insert stuff into selected region of file", edit_line => insert_between_region('## CF3 DO NOT EDIT START ##','## CF3 DO NOT EDIT END ##','/tmp/test_insert.txt'); } # Replace everything between start and end delimiters with our data bundle edit_line insert_between_region(sdelim, edelim, insert_file) { delete_lines: ".*" select_region => start_end('${sdelim}','${edelim}'), delete_select => example('${sdelim}','${edelim}'); insert_lines: "${insert_file}" select_region => start_end('${sdelim}','${edelim}'), insert_type => 'file'; } body delete_select example(s,e) { delete_if_not_match_from_list => { $(s), $(e) }; #delete_if_not_contains_from_list => { $(s), $(e) }; } body select_region start_end(start,end) { select_start => "$(start)"; select_end => "$(end)"; include_start_delimiter => "false"; include_end_delimiter => "false"; } _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine