sed -n 8p file  #print line 8
sed -n -e 1p -e 8p file   #print line 1 and line 8
sed -n 1,8p file    #print line 1 to line 8
sed -n -e 1,8p -e 20p file   #print line 1-8 and line 20

 -n:取消默认输出。注意:sed命令会默认把输入行打印到屏幕上,所以如果想精准的控制输出,就需要-n。

-e:进行多项编辑。即对输入行应用多项操作时使用。(和grep类似,多项操作的时候用 -e 参数)

p:打印行

posted on 2018-09-22 03:07  liuyihua1992  阅读(7239)  评论(0编辑  收藏  举报