I am posting this question because I am unable to add a comment to an answer submitted by Kusalananda here: "key = value" lines: how to replace a specific key's value?
He proposed the following solution:
sed -E 's/^(power[[:blank:]]*=[[:blank:]]*).*/\1something/' TheFile
Q1: What is the meaning of "\1"?
Q2: How can I modify this when dealing with key-value pairs with quotations around the value? e.g.
MTU="1500"
--- edit ---
Q3: In trying the suggestion from RalfFriedl I discovered that the name of my variable is being inserted, not the value.
sed -E 's/^(MTU[[:blank:]]*=[[:blank:]]*).*/\1$NewMtu/' MyEthFile
\1
refers to. For your second question, it is unclear what the issue is. To insert"150"
, use that string in place ofsomething
. – Kusalananda Sep 14 '18 at 18:11\1
, so start after the equals sign. – Jeff Schaller Sep 14 '18 at 18:55