I want to run a script that changes a line in the HTML code, indicating when the page was last updated. So for instance, I have the line
<d>This page was last updated on 29.04.2013 at 00:34 UTC</d>
and I am updating it now, so I want to replace that line with
<d>This page was last updated on 15.05.2013 at 15:50 UTC</d>
This is the only line in my source code that has the <d>
tag, so hopefully that helps. I already have some code that generates the new string with the current date and time, but I can't figure out a way to replace the old one (which changes, so I don't know exactly what it is).
I've tried putting in a comment <!--date-->
in the previous line, deleting the whole line that has <d>
(with grep
), and then putting in a new line after the comment that is the new string, but that fails. For example, if I want to just insert the string text
after the comment, and use
sed -i 's/<!--date-->/<!--date-->text/' file.html
I get invalid command code j
. I think it might be because there are some special characters like <
,!
, and >
in the strings, but if I want to put in the date string above, I will have even more, like :
and /
. Thanks for any ideas on how to fix this.