I am currently trying to automate updating the text of a file, titled original_file.txt. Imagine the file looks like the following:
common_text
### REPLACE EVERYTHING AFTER THIS LINE ###
text_that_will
be_removed
after_the_command
This file will be updated by removing all text after "Replace everything after this line", and replacing it with the text in the file replacement_file.txt. For the sake of the post, imagine that replacement_file.txt has the following text:
testing123
this_is_the_replacement_text
From what I've been able to find with sed, I can only figure out how to edit the rest of the line after a certain phrase. I want to replace the text in original_file.txt after the replacement phrase with all of the text from replacement_file.txt (I want to keep the replace line text for future updates). original_file.txt should look like this at the end:
common_text
### REPLACE EVERYTHING AFTER THIS LINE ###
testing123
this_is_the_replacement_text
Thanks in advance!
MATCH
was on the 1st line (assuming at least two lines of input) for reasons explained here at1:
. – don_crissti Mar 30 '20 at 13:31