Issue
I have into a text file the following line :
\[Omega]BD=100;
I would like to replace with gsed the value 100
by a shell variable (zsh shell), here 600
:
I tried :
$ i=600
$ gsed 's/\[Omega]BD=.*/\[Omega]BD=\'\\"$i"\\';/' text_to_modify.txt | grep 600
but it returns me :
\[Omega]BD=\600;
and not \[Omega]BD=600;
The is an additional backslash that I don't want, I wonder how could I remove this backslash. I would like to keep the two single quotes of gsed 's/.../.../'
Solution
Using sed
;
i=600
$ sed "/\[Omega]/s/[[:digit:]]\+/$i/" input_file
\[Omega]BD=600;
Answered By - HatLess Answer Checked By - Marilyn (WPSolving Volunteer)