sed: Replace part of a line

后端 未结 7 2083
渐次进展
渐次进展 2020-12-05 09:53

How can one replace a part of a line with sed?

The line

DBSERVERNAME     xxx

should be replaced to:

DBSERVERNAME           


        
7条回答
  •  [愿得一人]
    2020-12-05 09:58

    Try this

    sed -re 's/DBSERVERNAME[ \t]*([^\S]+)/\yyy/ig' temp.txt

    or this

    awk '{if($1=="DBSERVERNAME") $2 ="YYY"} {print $0;}' temp.txt

提交回复
热议问题