Reputation: 23
I have a list as below;
paramone=somerandomvalue; paramtwo=somerandomvalue; paramthree=somerandomvalue;
I want to append a * (asterisk) at the end of every 'somerandomvalue' but before ; (semicolon) like below -
paramone=somerandomvalue*; paramtwo=somerandomvalue*; paramthree=somevrandomalue*;
NOTE - It should only append the strings that have = and ; . There are other strings having ; at the end but doesn't have a =.
Upvotes: 1
Views: 177
Reputation: 11227
Assuming your input had the following content
$ cat input_file
paramone=somerandomvalue; paramtwo=somerandomvalue; paramthree~somerandomvalue;paramone=somerandomvalue; paramtwo=somerandomvalue; paramthree##somerandomvalue;
Using sed
$ sed s'/\(=[^;]*\)/\1*/g' input_file
paramone=somerandomvalue*; paramtwo=somerandomvalue*; paramthree~somerandomvalue;paramone=somerandomvalue*; paramtwo=somerandomvalue*; paramthree##somerandomvalue;
Upvotes: 3
Reputation: 609
I'd leverage sed
to do this:
sed 's/;/*;/g' test.txt
Something like that. Assuming every value has that ;
at the end of it.
Upvotes: 3