How can I can insert the contents of a file into another file right before a specific line

前端 未结 5 542
囚心锁ツ
囚心锁ツ 2020-12-05 07:46

How can I can insert the contents of a file into another file right before a specific line using sed?

example I have file1.xml that has the following:



        
5条回答
  •  误落风尘
    2020-12-05 08:35

    Usually I do like this:

    1. file1, file to read insert content
    2. file2, insert reading content from file1 to at the head of file2
    3. script snippet:

      sed "\$r ${file2}" ${file1} > tmpfile
      mv tmpfile ${file2}

提交回复
热议问题