码迷,mamicode.com
首页 > 系统相关 > 详细

linux查询文件中某几行

时间:2017-01-10 19:37:24      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:方法   查看   file   cat   显示   etc   style   code   nbsp   

查询文件中某几行:

sudo cat /etc/tinyproxy.conf | head -n 32 | tail -n +29

 

 

【一】从第3000行开始,显示1000行。即显示3000~3999行

cat filename | tail -n +3000 | head -n 1000

 

【二】显示1000行到3000行

cat filename| head -n 3000 | tail -n +1000

 

*注意两种方法的顺序

 

分解:

    tail -n 1000:显示最后1000行

    tail -n +1000:从1000行开始显示,显示1000行以后的

    head -n 1000:显示前面1000行

 

【三】用sed命令

 

 sed -n ‘5,10p‘ filename 这样你就可以只查看文件的第5行到第10行。

linux查询文件中某几行

标签:方法   查看   file   cat   显示   etc   style   code   nbsp   

原文地址:http://www.cnblogs.com/haochuang/p/6270202.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!