Results 1 to 3 of 3
I want to replace a line using sed. The problem is that the original line will not have always the same value but will start with a specific word. For ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 06-15-2012 #1
- Join Date
- Jun 2012
Sed to replace entire line
domain = example.com #domain will always be domain but example.com will not always be the same
sed -i 's/domain = example.com/domain = newdomain.com/' file.txt
Any suggestions ?
- 06-15-2012 #2Code:
sed -e "/^domain = / c\domain = newdomain.com" file.txt
You maybe want to modify the regex to accept whitespaces.
Once the sed line does what you want, add the -i switch.You must always face the curtain with a bow.
- 06-16-2012 #3
I'd do it
sed -i '.bak' -e"/^domain = .*$/domain = newdomain.com" file.txt/"