Hi this is what I'm trying to do:
ruby_block "modify line" do
block do
file= Chef::Util::FileEdit.new("/someExistingFile.txt")
file.insert_line_if_no_match(/^11$/, "#this is a comment\n#11")
file.search_file_replace_line(/^#11$/, "11")
file.write_file
end
end
After applying the cookbook it adds '11' but I don't see the '#this is a comment' line.
is it possible to run this two lines consecutively?
file.insert_line_if_no_match(/^11$/, "#this is a comment\n#11")
file.search_file_replace_line(/^#11$/, "11")
Expected output [someExistingFile.txt]:
#this is a comment
11
Actual output [someExistingFile.txt]:
11
In addition I changed it around like this:
file.insert_line_if_no_match(/^11$/, "#this is a comment\n#11")
file.search_file_replace_line(/^#this is a comment$/, "this is a comment")
Expected output [someExistingFile.txt]:
this is a comment
#11
Actual output [someExistingFile.txt]:
this is a comment
It seems that even tough the new line added had a \n
the search_file_replace_line
thinks as both as 1 line!! why?