删除匹配的下一行到最后一行 [root@test200 ~]# cat test a b c d e f [root@test200 ~]# sed '/c/{p;:a;N;$!ba;d}' test a b c 定义一个标签a,匹配c,然后N把下一行加到模式空间里,匹配最后一行时,才退出标签循环,然后命令d,把这个模式空间里的内容全部清除. if 匹配"c" :a 追加下一行 if 不匹配"$" goto a 最后退出循环,d命令删除. 删除匹配行和匹配行后的2行
“p” command prints the buffer (remember to use -n option with “p”) “d” command is just opposite, its for deletion. ‘d’ will delete the pattern space buffer and immediately starts the next cycle. Syntax: # sed 'ADDRESS'd filename # sed /PATTERN/d file
sed 删除最后几行 和删除指定行 转载原文链接:http://blog.51cto.com/lspgyy/1305489 sed 想删除文件中的指定行,是可以用行号指定也可以用RE来匹配的. 删除指定的行[可以指定行号删除.匹配字符串来删除] [root@Jason64-17 ~]# cat -n seq.txt 1 ok i will help you 2 understand sed usage 3 how to use it 4 and we should use it in vie
用sed删除空行 我的代码如下:class Song def initialize(name) @name = name end def tell puts @name end end class ZhouSong < Song def initialize(name,artist) super(name) @artist = artist end def tell super puts @ar