Replace all sub-domain names in a file with a different domain name using wildcard.
Ex : In a file, I have the following domains :
example1.domain1.com
example2.domain1.com
example3.domain1.com
I want to replace these sub-domain names with domain2.com. I tried using the below sed command. It works fine if the file size is small. But for large file it looks like the command execution never ends. I want to use a wildcard here since the text to be replaced have the same domain name i.e domain1.com.
sed -i s/.*.domain1.com/domain2.com/g test.txt