I have a text file containting this
Var1=ofzer
Var2=smelf
..
..
VarN=mskfm
I want to change the value of one of my variables using Sed. How is that possible?
I have a text file containting this
Var1=ofzer
Var2=smelf
..
..
VarN=mskfm
I want to change the value of one of my variables using Sed. How is that possible?
Say you wanted to change the value of Var2 from 'smelf' to 'smurf', you could use:
bash$ sed -i 's/Var2=.*/Var2=smurf/' file.txt
In case you want more complex substitution:
sed_param=s/Var1=.*/Var1=${NEW_VALUE}/
sed -i "$sed_param" file.txt