使用sed在指定行尾插入字符
2016-06-29 16:11
561 查看
例如在server行的行尾插入指定字符:
如果文件这样也可以,因为 /^server/ 限定了 只是行头是
server 才在行尾插入字符
nc10@your-5554c55be4 ~ $ cat sheet server 127.0.0.1 localhost connected yes 12-3-08 server 127.0.0.1 localhost connected no 12-3-08 server 127.0.0.1 localhost connected yes 14-9-09 server 127.0.0.1 localhost connected yes 15-9-09 server 127.0.0.1 localhost connected no 16-9-09 nc10@your-5554c55be4 ~ $ sed '/^server.*$/s//& test/g' sheet server 127.0.0.1 localhost connected yes 12-3-08 test server 127.0.0.1 localhost connected no 12-3-08 test server 127.0.0.1 localhost connected yes 14-9-09 test server 127.0.0.1 localhost connected yes 15-9-09 test server 127.0.0.1 localhost connected no 16-9-09 test
如果文件这样也可以,因为 /^server/ 限定了 只是行头是
server 才在行尾插入字符
user@minix-nb:~$ cat sheet remote 127.0.0.1 localhost connected yes 12-3-08 server 127.0.0.1 localhost connected no 12-3-08 remote 127.0.0.1 localhost connected yes 14-9-09 server 127.0.0.1 localhost connected yes 15-9-09 remote 127.0.0.1 localhost connected no 16-9-09 user@minix-nb:~$ sed '/^server.*$/s//& test/g' sheet remote 127.0.0.1 localhost connected yes 12-3-08 server 127.0.0.1 localhost connected no 12-3-08 test remote 127.0.0.1 localhost connected yes 14-9-09 server 127.0.0.1 localhost connected yes 15-9-09 test remote 127.0.0.1 localhost connected no 16-9-09
相关文章推荐
- maven安装及插件安装和配置
- 【转载】AdaBoost / Decision Stumps
- findbugs, checkstyle, pmd的myeclipse7.5+插件安装(转:http://blog.csdn.net/priestmoon/article/details/63941)
- Linux下四款Web服务器压力测试工具(http_load、webbench、ab、siege)介绍
- CEF3开发者系列之JS与C++交互之二
- BP神经网络解决XOR异或运算python示例
- 远程调试监视器(MSVSMON.EXE)似乎没有在远程计算机上运行“的完美解决方案
- 机器人操作系统ROS Indigo 入门学习(16)——记录和重放数据
- MyEclipse9安装Checkstyle5.5插件(图解)
- 在eclipse导入的工程,工程上就有红叉,而里面都没有红叉,是怎么回事??
- 格式化选项带html标签的combobox
- MyEclipse9安装Checkstyle5.5插件(图解)
- jquery的下拉选择框
- hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)
- 【Object-c基础】预定义,条件编译,数组
- 机器人操作系统ROS Indigo 入门学习(15)——验证简单的service和client
- Junit使用教程(四)
- java.text.DecimalFormat 工具类
- 机器人操作系统ROS Indigo 入门学习(14)——用C++语言写一个简单的service和client
- 如何在haproxy的后端服务器查看客户端的IP?