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

后端 未结 4 1555
无人及你
无人及你 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:22

    You can't replace one line with another in place. Because lines usually has different length and will overlap each other. If all lines in your file are the same length then it can work. I also suggest you use more suitable language for this task (like Perl for example) because it will be really complicated code in Shell. I think that you should look for a solution with temporal files, because it'll easier to implement and it can be debugged easily. Just imagine what will you do if your huge file will be currupted due to the bug in the script.

提交回复
热议问题