在文档的某行插入内容

回复 收藏
#如果知道行号可以用下面的方法

sed -i '88 r b.file' a.file    #在a.txt的第88行插入文件b.txt

awk '1;NR==88{system("cat b.file")}' a.file > a.file


#如果不知道行号,可以用正則匹配

sed -i '/regex/ r b.txt' a.txt # regex是正则表达式

awk '/target/{system("cat b.file")}' a.file > c.file


2014-04-14 17:02 举报
已邀请:
0

lyhabc

赞同来自:

sed -i '8c\\n\extension = "pdo_mysql.so"' /usr/local/etc/php.ini
行号,定址

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: