How can one replace a part of a line with sed?
The line
DBSERVERNAME xxx
should be replaced to:
DBSERVERNAME yyy
The value xxx can vary and there are two tabs between dbservername and the value. This name-value pair is one of many from a configuration file.
I tried with the following backreference:
echo "DBSERVERNAME xxx" | sed -rne 's/(dbservername)[[:blank:]]+([[:alpha:]]+)/1 yyy/gip'
and that resulted in an error: invalid reference 1 on `s' command's RHS.
Whats wrong with the expression? Using GNU sed.
question from:
https://stackoverflow.com/questions/1074450/sed-replace-part-of-a-line 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…