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

shell 题

时间:2016-12-19 08:07:19      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:提取   cut   字母   主机   one   gre   内容   post   sed   

(1)有一推主机地址:

a.baidu.com
.....
z.baidu.com

如何从这些数据中提取出.baidu.com之前的字母,如:a b...z?

#cat f1.txt | while read line; do echo ${line%%.*}; done

#awk -F‘.‘ ‘{print $1}‘ f1.txt

(2)处理以下文件内容,将域名取出并进行计数排序,如处理
oldboy.log
http://www.etiantian.org/index.html
http://www.etiantian.org/1.html
http://post.etiantian.org/index.html
http://mp3.etiantian.org/index.html
http://www.etiantian.org/3.html
http://post.etiantian.org/2.html

#cut -d‘/‘ -f3 f2.txt |sort| uniq -c

#awk -F‘/‘ ‘{print $3}‘ f2.txt | sort | uniq -c

#sed ‘s/^htt.*\/\///g‘ f2.txt | sed ‘s/\/.*html$//g‘  | sort | uniq -c

#cat f2.txt |tr ‘\/‘ ‘\n‘ | grep etiantian | sort | uniq -c

 

shell 题

标签:提取   cut   字母   主机   one   gre   内容   post   sed   

原文地址:http://www.cnblogs.com/Berryxiong/p/6196072.html

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