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

linux命令之文件内容定位:sed、uniq命令

时间:2017-05-14 16:58:14      阅读:316      评论:0      收藏:0      [点我收藏+]

标签:内容   print   sed   bsp   统计   网站   之间   打印   http   

sed命令

1、sed -n ‘2‘p  file

     只打印 file 文件的第二行。

 

2、sed -n ‘1,4‘p file

    只打印从第一行到第四行得记录。

 

3、sed -n ‘/los/‘p file

     打印匹配los的行。

 

4、sed -n ‘4,/los/‘p file

     打印从第四行到匹配los的之间的所有行。

 

5、sed ‘1,2‘d file

     把第一行和第二行全部删除。

uniq命令

1、uniq -c file

    打印紧挨的重复行出现的次数。

 

2、uniq -d file

     只打印重复的行。

 

3、awk ‘{print $1}‘ /var/log/httpd/access_log|sort|uniq -c

     把apache网站的所有访问ip全部统计出来,并打印出统计次数。

linux命令之文件内容定位:sed、uniq命令

标签:内容   print   sed   bsp   统计   网站   之间   打印   http   

原文地址:http://www.cnblogs.com/lanchang/p/6850348.html

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