I would like to edit a file containing a set of email ids such that all the domain names become generic.
Example,
peter@yahoo.com,
julie@hotmail.com,
philip@gmail.com
to
peter@generic.com,
julie@generic.com,
philip@generic.com
I used the following sed command,
sed '/@/,/.com/ s//generic/' filename.txt
here the sed replaces ‘@’ with ‘generic and .com with ‘generic’ and not the content in between @ and .com
Use
This will replace everything after the “@” until the first comma with generic.com, thereby fixing the domain, and leaving the ending comma in tact.
Since you seem to have some confusion, ranges (
/regex/,/otherregex/) select a number of lines, not positions within a line.