码迷,mamicode.com
首页 > 其他好文 > 详细

只查看ett.txt文件(共100行)内第25到35行的内容的八种解决方法

时间:2017-07-19 14:19:26      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:查找内容

试题:只查看ett.txt文件(共100行)内第25到35行的内容

解答:

方法一:head -35 /data/ett.txt |tail -11

方法二:sed -n ‘25,35p‘ /data/ett.txt

方法三:grep -C5 30 /data/ett.txt

方法四:grep -A10 25 /data/ett.txt

方法五:grep -B10 35 /data/ett.txt

方法六:awk ‘NR=25,NR==35‘ /data/ett.txt 

方法七:awk ‘NR>24&&NR<36‘ /data/ett.txt 

方法八: awk ‘{if(NR>24&&NR<36) print $0}‘ /data/ett.txt

注:上面grep的方法,不适合取文件中的内容。


只查看ett.txt文件(共100行)内第25到35行的内容的八种解决方法

标签:查找内容

原文地址:http://congzz.blog.51cto.com/12548626/1948845

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