Reputation: 721
I have a text file:
a b n
d f h
e f y
I want to edit it and make it like:
a [email protected] n
d [email protected] h
e [email protected] y
How can I do this? Is there any command which can help?
Upvotes: 0
Views: 2425
Reputation: 58371
This might work for you (GNU sed):
sed -i 's/\S\+/&@gmail.com/2' file
Upvotes: 0
Reputation: 784998
Using sed inline
:
sed -i.bak 's/\(^[^ ]* *\)\([^ ]*\)\(.*\)$/\1\[email protected]\3/' file
This will save the changes in the original file itself.
Upvotes: 2
Reputation: 33317
Try this awk one liner:
$ awk '$2=$2"@gmail.com"' file
a [email protected] n
d [email protected] h
e [email protected] y
Upvotes: 5