标签:starting address example linux stream
有命令如下:
1.sed -n ‘1~2!p‘ datafile
该条命令的意思是:每两行读取datafile文件到模式空间,匹配每两行中的第一行,不打印,剩下的行打印,取消默认输出。
2.sed -n ‘1~2p‘ datafile
该条命令的意思是:每两行读取datafile文件到模式空间,匹配每两行中的第一行,打印,剩下的行不打印,取消默认输出。
3.sed ‘1~2d‘ datafile
这条命令和第一条命令等同。
附:Linux中sed的命令手册相关解释
first~step
Match every step’th line starting with line
first. For example, ‘‘sed -n 1~2p’’ will print
all the odd-numbered lines in the input stream,
and the address 2~5 will match every fifth line,
starting with the second. first can be zero; in
this case, sed operates as if it were equal to
step. (This is an extension.)
标签:starting address example linux stream
原文地址:http://lielie.blog.51cto.com/3946919/1535421