sed输出指定行

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:进行多项编辑。即对输入行应用多项操作时使用。

p:打印行

猜你喜欢

转载自www.cnblogs.com/liuyihua1992/p/9689296.html
今日推荐