更新时间:2023-02-21 15:33:27
sed's / ^ volume =。* / volume = 0 / g'file.txt
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