shell - Replacing domains of e-mail addresses with just one domain -


i edit file containing set of email ids such domain names become generic.

example, peter@yahoo.com, julie@hotmail.com, philip@gmail.com  peter@generic.com, julie@generic.com, philip@generic.com 

i used following sed command,

sed '/@/,/.com/ s//generic/' filename.txt 

here sed replaces '@' 'generic , .com 'generic' , not content in between @ , .com

use

sed 's/@[^,]*/@generic.com/' 

this replace after "@" until first comma generic.com, thereby fixing domain, , leaving ending comma in tact.

since seem have confusion, ranges (/regex/,/otherregex/) select number of lines, not positions within line.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -