linux用sed在文件最前面插入一行


https://blog.51cto.com/sunday208/1387054

linux用sed在文件最前面插入一行

 

如何在文件的最开头插入一行字符串呢?

sed -i '1s/^/内容/' 文件名

例如:

sed -i '1s/^/#by Lflakf \n\n/' a.txt


===========================

我的

[root@ffcs211 xx]# ls *|xargs sed -i '1s/^/\/\/source file use encoding=\"GB18030\"\r\n/'
[root@ffcs211 xx]# cat a.txt
//source file use encoding="GB18030"

posted @ 2022-02-17 18:29  暴风城  阅读(4239)  评论(0编辑  收藏  举报