shell 题
2016-12-19 00:15
127 查看
(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
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 零起点学习(4)
- linux c程序中获取shell脚本输出
- 在awk里引用shell变量(支持正则)
- Shell脚本入门的几个很实用的基础命令
- shell执行过程
- shell算术运算与进制运算
- Shell传入参数的处理
- Shell - 11
- 使用Shell脚本查找程序对应的进程ID,并杀死进程
- 如何调试shell脚本
- shell脚本进行数据库查询(分库分表)
- [shell] hello,shell
- linux的Shell脚本程序
- SHELL里如何得到N天以前或以后的日期格式
- Windows API —— ShellExcute——打开文件
- Shell检验IP合法性
- windows下调用外部exe程序 SHELLEXECUTEINFO
- 排序(4)---------希尔(shell)排序(C语言实现)
- shell中截取字符串方法总结
- 对log进行shell方法处理