Assuming the part for user_value is always 3 characters long you can do it like this:
Or if you be sure there is nothing behind in that line you aswell could use:
I hope i got that REGEX right, I'm no pro in this. So the value should be all the time 3 characters long best in hex format because decimal doesn't be always 3 characters long in cases below 100. The second case should work even i the number is below 100 but it assumes the whole
name_of_the_value=user_value part is in a line of its own. Now testing this in terminal the output looks like this for the second case:
video@NAUTH:~$ echo "name_of_the_value=xxx" | sed "s/name_of_the_value=.*/name_of_the_value=$USER/"
Of course you need to pipe the output back into the file, or use a temporary file to swap around. You could use:
sed "s/name_of_the_value=.*/name_of_the_value=$new_value/" /input_file | sponge /input_file
Sed only changes the output while reading the file, not writing it, sponge saves the output then until you are through and writes the changes back.
If you don't want to or can't use sponge write in a second file and then switch them like this chain of commands.
sed "s/name_of_the_value=.*/name_of_the_value=$new_value/" /input_file > /output_file
rm -v /input_file
mv -v /output_file /input_file
As @kos pointed out in the comment you can as well use the
-i flag of the
sed command to write back into the input file without the use of a temporary file or
sed -i "s/name_of_the_value=.*/name_of_the_value=$new_value/" /input_file