How to Replace a line in the same file by SED in Unix Shell scripting?

后端 未结 4 1620
无人及你
无人及你 2021-01-21 20:59

In Reference to this question After getting the line identifier matching in first and second file I need to replace the line in first file with the line of second file.For that

4条回答
  •  醉酒成梦
    2021-01-21 21:45

    Have a look at sponge which is part of moreutils.

    e.g.

    % sed "s/root/toor/" /etc/passwd | grep -v joey | sponge /etc/passwd
    

提交回复
热议问题