It would be helpful if you would explain how it didn't work, not just that it didn't work.
I see you have resolved it while I was trying to get my own reply past the CloudFlake police, so I will add that it would be helpful to future visitors if you wold also post your solution.
First, the escaped '?' in the replacement text is also unnecessary.
You have the use of the escaped '?' backwards - it needs to be escaped when using extended regular expressions (sed -r), not when using basic regular expressions as you are doing. From the
GNU sed manual:
Code:
The only difference between basic and extended regular expressions
is in the behavior of a few characters: ‘?’, ‘+’, parentheses, and braces
(‘{}’). While basic regular expressions require these to be escaped if
you want them to behave as special characters, when using extended
regular expressions you must escape them if you want them to match a
literal character.
So, in your example, this should work:
Code:
sed -i 's/<h3><?php/<h3 class="DateHeader"><?php/g'
Otherwise this should work with extended regular expressions:
Code:
sed -ri 's/<h3><\?php/<h3 class="DateHeader"><?php/g'
Or simply put the '?' inside square brackets:
Code:
sed -ri 's/<h3><[?]php/<h3 class="DateHeader"><?php/g'
...which should work in either case.