I want to refactor many JavaScript files in many directories which contain access to an object in this format: myObj.something.somethingElse
and I want it to be myObj.getSomething(somethingElse)
how can I achieve this in shell?
1 Answer
You could probably give Sed (the stream editor) a try using it's replacement command s/regexp/replacement/
.
sed
and a concept known as a backreference. In the abstract, your question is similar to the one answered here. You may find other helpful duplicates by filtering on the[sed]
tag and searching forbackreference
..something
and the second has.getSomething
... is that correct or should the second also be.something
? Or it is that, that you wish to replace, i.e.s/.something/.getSomething/
Please clarify and give accurate examples.