$Subj .= "HAD PROBLEMS";
if ($To) {
$Cc = "abc\@xyz.com";
}
else {
$Cc = "abc\@xyz.com";
}
I have the above text in a file. I need to replace the email id in $Cc with a new email id.
I have the following sed command to do so.
sed '\|HAD PROBLEMS|,/}/ s/$Cc = (\"[A-Za-z0-9])(.)([A-Za-z0-9]*)\@xyz.com\"/\$Cc = "new email\@xyz.com"/' test.txt
This command will replace the email id only for the $Cc variable in the if {} block (first occurrence of $Cc) since my ending match pattern is a '}'. I want to replace email id in the second $Cc as well. how do i match on the 2nd occurrence of '}' ?