I have a series of javascript .js files where the original scripter used poor variable names such as 'a', 'b', etc.
I need to automate the substitution to more descriptive names, reliably only changing the single character variable name(s) and not erroneously modifying other variables which may include that letter.
I am thinking it could be done in awk with something like:
awk '{gsub(/a/, "new_name")};{print}' script.js
but need more sophistication in the regular expression /a/ so as not to change variable names erroneously.
I have created a file named charac-sub.awk with:
{gsub(/\/,"new_name1")}; {print}
{gsub(/\/,"new_name2")}; {print}
. .
and when I run it from the command line:
awk -f charac-sub.awk gs_script.js
It seems to do what I need. – Debra McCusker Oct 02 '20 at 20:29