(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
时间: 2024-10-11 00:20:21