I've spent an hour each day searching for ways to use sed for replacing below sample data as practice. Hope someone could guide and correct me on using sed properly to achieve the right output.
sample.txt
User's name is adam
Account's name is adam_acc
User's name is adam.eve
Account's name is adam.eve_acc
Output trying to achieve:
User's name is user_1
Account's name is user_3
User's name is user_2
Account's name is user_4
Attempt tried:
$ sed 's/\<adam\>/user_1/g;
s/\<adam\.eve\>/user_2/g;
s/\<adam\_acc\>/user_3/g;
s/\<adam\.eve_acc\>/user_4/g' sample.txt
Attempt's output:
User's name is user_1
Account's name is user_3
User's name is user_1.eve
Account's name is user_1.eve_acc
Below is the bash version I am currently using:
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Material which I had read for more info:
https://www.gnu.org/software/sed/manual/html_node/Regular-Expressions.html
https://www.gnu.org/software/sed/manual/html_node/sed-regular-expressions.html#sed-regular-expressions