append a text on the top of the file

前端 未结 6 870
借酒劲吻你
借酒劲吻你 2020-12-20 16:29

I want to add a text on the top of my data.txt file, this code add the text at the end of the file. how I can modify this code to write the text on the top of my data.txt f

6条回答
  •  一向
    一向 (楼主)
    2020-12-20 17:02

    There is a much simpler one-liner to prepend a block of text to every file. Let's say you have a set of files named body1, body2, body3, etc, to which you want to prepend a block of text contained in a file called header:

    cat header | perl -0 -i -pe 'BEGIN {$h = }; print $h' body*
    

提交回复
热议问题