1. 指定字符前面添加 sed -i 's/指定的字符/需要添加的字符&/' 文件名稱 修改Linux啟動配置 將 GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb ...
https: blog.csdn.net qq article details https: www.cnblogs.com zqingfeng p .html ...
2021-01-05 10:11 0 425 推薦指數:
1. 指定字符前面添加 sed -i 's/指定的字符/需要添加的字符&/' 文件名稱 修改Linux啟動配置 將 GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb ...
[root@Cobbler logs]# cat aa.txt qqq123ppp123====123[root@Cobbler logs]# sed -i '2,5s#123#456#' aa.txt [root@Cobbler logs]# cat aa.txt qqq456ppp456 ...
sed多看幫助文檔,受益良多 例如刪除 /etc/profile的最后一行 cat -n /etc/profile ... 101 export PATH=/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin ...
^([^@]*)@.*$ $1 ...
如下文本 zimu.txt aaaaa #bbbbbb cccccc dddddd 以下命令如果需要在文本中更改 需要加 -i 或者 -ri參數 用sed在aaa前加#注釋 sed 's/^aaa/#&/' zimu.txt # &的意思是匹配 ...
1. 修改指定字符后面的隨機內容 例:修改mcctconf中testrun:后面的隨機內容為xxx 例:打印sed修改mcctconf中testrun:后面的隨機內容為xxx所在整行內容 例:打印sed在mcctconf中指定testrun:后面的添加內容為xxx ...
假設文檔內容: 1.要求:在1111之前添加AAA,方法如下: sed -i 's/指定的字符/要插入的字符&/' 文件 2、要求:在1111之后添加BBB,方法如下: sed -i 's/指定的字符/&要插入的字符/' 文件 ...
一、在匹配行前后加內容在包含www.baidu.com的行前面或后面添加多一行內容www.qq.com#匹配行前加sed -i '/www.baidu.com/i www.qq.com' domain.file#匹配行后加sed -i '/www.baidu.com ...