linux sed 命令

aa bb cc

Hello world! Hello Jack! Hello China! Hello Nick!

$ test.txt # 删除第二行到最后一行

选项 -i

$ -i '1d' test.txt

$ test.txt # 在第一行下面新增一行,内容为 test.txt # 在最后一行下面新增一行,内容为 , test.txt # 一次增加多行需要使用换行符 \n

$ -e '1a xxx' -e '2a yyy' test.txt

1i Hello world! 2i Hello world! 3i Hello world!

$ -f commands test.txt

$ test.txt # 把第一行替换为 test.txt # 把第一行到第三行替换为

$ hello.txt # 把Hello 替换为 Hi

$ hello.txt # 把匹配到的所有Hello 都替换为 Hi

$ hello.txt # 只在第二行和第三行进行替换操作

$ hello.txt # 删除字符串 Hello

$ -n test.txt 和命令sed -n hello.txt

$ -n -n -n -n test.txt # 匹配第三行和第三行后的每一行

$ -n hello.txt

$ -n hello.txt

$ hello.txt # 找到匹配的行,在这些行中执行替换

$ -i -i my.cnf

相关文章

/etc/sysctl.conf这个目录主要是配置一些系统信息,/etc/sys...
1.作用 useradd或adduser命令用来建立用户帐号和创建用户的起...
它们都是多模式编辑器,不同的是vim 是vi的升级版本,它不仅...
不管是我们在安装软件还是监测软件的使用性能,我们都要随时...
装好Tomcat7后,发现除了本机能访问外界访问不了,岂有此理。...
修改防火墙配置需要修改 /etc/sysconfig/iptables 这个文件,...