Replace whole line when match found with sed

前端 未结 4 1779
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-07 20:25

I need to replace the whole line with sed if it matches a pattern. For example if the line is \'one two six three four\' and if \'six\' is there, then the whole

4条回答
  •  天涯浪人
    2020-12-07 20:42

    This might work for you (GNU sed):

    sed -e '/six/{c\fault' -e ';d}' file
    

    or:

    sed '/six/{c\fault'$'\n'';d}' file
    

提交回复
热议问题