I'd like to do the following, but I can't seem to find an elegant way to do it.
I have a text file that looks like this:
..more values
stuff = 23
volume = -15
autostart = 12
more values..
Now the "volume" value may change, depending on the circumstance. I need a script that can find that line of text with "volume = xxx" then replace it with the line "volume = 0". What is an elegant solution to this? This line in the text is not guaranteed to be the first line, so I need a way to find it first.
sed 's/^volume =.*/volume = 0/g' file.txt
With sed you can say:
sed '/^volume/s/.*/volume = 0/' infile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With