求个sed命令 在文本开头插入内容

60次阅读

共计 1148 个字符,预计需要花费 3 分钟才能阅读完成。

文件 blocklist.rsc 内容如下 ——————————————————————–google.comy2b.com… 变成 ——————————————————————–# RouterOS Split DNS# 创建时间 /ip/dns/static/remove [find type=FWD]/ip dns staticadd address-list=test forward-to=1.1.1.1 match-subdomain=yes type=FWD name=google.comadd address-list=test forward-to=1.1.1.1 match-subdomain=yes type=FWD name=y2b.com… nkym 2022-12-06 21:22 2 我网站有,挂上 t 打开 google.com KDE 2022-12-06 21:26 3nkym 发表于 2022-12-6 21:22 我网站有,挂上 t 打开 google.com 那么请问行首加下面内容,该怎么办呢?add address-list=test forward-to=1.1.1.1 match-subdomain=yes type=FWD name= 在文件开头插入文本通过可在脚本中使用的 ed 单命令行程序,您可以容易地在文件开头插入文本。插入操作是使用 ed 并通过 a 命令将给定文本追加到第 0 行(文件开头)来完成的:$ cat fileThis is the end.$ (echo \’0a\’; echo \’This is the beginning.\’; echo \’.\’; echo \’wq\’) | ed -s file$ cat fileThis is the beginning.This is the end. 版权声明:本文为 CSDN 博主「tim_szchina」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/tim_szchina/article/details/83890501 懒无止境丶 2022-12-06 21:55 4sed -e \’1i # RouterOS Split DNS\\n# 创建时间 \\n\\n/ip/dns/static/remove [find type=FWD]\\n/ip dns static\’ -e \’s/^/add address-list=test forward-to=1.1.1.1 match-subdomain=yes type=FWD name=/g\’ blocklist.rsc 复制代码

正文完
 0