转(linux shell)(2)
1、按单词出现频率降序排序!2、按字母出现频率降序排序!the squid project provides a number of resources to assist users design,implement and support squid installations. Please browse the documentation and support sections for more infomation解答:cat test.txt the squid project provides a number of resources to assist users design,implement and support squid installations. Please browse the documentation and support sections for more infomation按单词排序解答:法1:[root@oldboy ~]# awk -F "[,. ]" '{for(i=1;i<=NF;i++)array[$i]++}END{for(key in array)print array[key],key|"sort -nr"}' oldboy.txt|column -t2 the2 support2 squid2 and1 users1 to1 sections1 resources1 provides1 project1 Please1 of1 number1 more1 installations1 infomation1 implement1 for1 documentation1 design1 browse1 assist1 a1法2:[root@MySQL ~]# tr "[ ,.]" "\n"<oldboy.txt|grep -v "^$"|sort|uniq -c|sort -rn 2 the 2 support 2 squid 2 and 1 users 1 to 1 sections 1 resources 1 provides 1 project 1 Please 1 of 1 number 1 more 1 installations 1 infomation 1 implement 1 for 1 documentation 1 design 1 browse 1 assist 1 a按字母频率排序法1[root@MySQL ~]# tr "{ |,|.}" "\n"<oldboy.txt|awk -F "" '{for(i=1;i<=NF;i++)array[$i]++}END{for(key in array)print array[key],key|"sort -nr"}'19 s17 e16 o14 t12 n12 i11 r9 a8 u7 p7 d6 m4 l4 c3 f2 q2 h2 b1 w1 v1 P1 j1 g[root@MySQL ~]# tr "[ ,.]" "\n"<oldboy.txt|awk '{for(i=1; i<=length($0); i++) ++S[substr($0,i,1)]} END {for(a in S) print S[a], a|"sort -rn"}'19 s17 e16 o14 t12 n12 i11 r9 a8 u7 p7 d6 m4 l4 c3 f2 q2 h2 b1 w1 v1 P1 j1 g[root@db02 oldboy20151227]# echo "the squid project provides a number of resources toassist users design,implement and support squid installations. Please browsethe documentation and support sections for more infomation"|sed 's# ##g'|sed -r 's#(.)#\1\n#g'|sort|uniq -c|sort -rn -k1 19 s 17 e 16 o 14 t 12 n 12 i 11 r 9 a 8 u 7 p 7 d 6 m 4 l 4 c 3 f 2 q 2 h 2 b 1 w 1 v 1 j 1 g 1 P 1 . 1 , 1 [root@db02 oldboy20151227]# echo "the squid project provides a number of resources toassist users design,implement and support squid installations. Please browsethe documentation and support sections for more infomation"|sed 's# ##g'|awk -F "" '{for(n=1;n<=NF;n++) print $n}'|sort|uniq -c|sort -k1 -nr 19 s 17 e 16 o 14 t 12 n 12 i 11 r 9 a 8 u 7 p 7 d 6 m 4 l 4 c 3 f 2 q 2 h 2 b 1 w 1 v 1 j 1 g 1 P 1 . 1 ,转(linux shell)(2)的更多相关文章
- linux shell 中的sleep命令
开始还以为是这样的语法: sleep(1), 后面发现是: linux shell 中的sleep命令 分类: LINUX 在有的shell(比如linux中的bash)中sleep还支持睡眠(分,小 ...
- Linux shell脚本编程(三)
Linux shell脚本编程 流程控制: 循环语句:for,while,until while循环: while CONDITION; do 循环体 done 进入条件:当CONDITION为“真” ...
- Linux shell脚本编程(二)
Linux shell脚本编程(二) 练习:求100以内所有偶数之和; 使用至少三种方法实现; 示例1: #!/bin/bash # declare -i sum=0 #声明一个变量求和,初始值为0 ...
- Linux shell脚本编程(一)
Linux shell脚本编程: 守护进程,服务进程:启动?开机时自动启动: 交互式进程:shell应用程序 广义:GUI,CLI GUI: CLI: 词法分析:命令,选项,参数 内建命令: 外部命令 ...
- Linux Shell 流程控制语句
* 本文主要介绍一些Linux Shell 常用的流程控制语句* 1. if 条件语句:if-then/if-elif-fi/if- else-fi if [条件判断逻辑1];then command ...
- Linux Shell 截取字符串
Linux Shell 截取字符串 shell中截取字符串的方法很多 ${var#*/} ${var##*/} ${var%/*} ${var%%/*} ${var:start:len} ${var: ...
- Linux Shell 重定向与管道【转帖】
by 程默 在了解重定向之前,我们先来看看linux 的文件描述符. linux文件描述符:可以理解为linux跟踪打开文件,而分配的一个数字,这个数字有点类似c语言操作文件时候的句柄,通过句柄就可以 ...
- Linux Shell 通配符、元字符、转义符【转帖】
作者:程默 说到shell通配符(wildcard),大家在使用时候会经常用到.下面是一个实例: 1 1 2 3 4 [chengmo@localhost ~/shell]$ ls a.txt ...
- Linux Shell中单引号、双引号、反引号的区别【转载】
linux shell可以识别4种不同类型的引字符号: 单引号字符' 双引号字符" 反斜杠字符\ 反引号字符` 1. 单引号 ( '' )# grep Susan phonebook Sus ...
- 【shell 大系】Linux Shell常用技巧
在最近的日常工作中由于经常会和Linux服务器打交道,如Oracle性能优化.我们数据采集服务器的资源利用率监控,以及Debug服务器代码并解决其效率和稳定性等问题.因此这段时间总结的有关Linux ...
随机推荐
- 理解HMM
hidden markov model markov model: 把一个总随机过程看成一系列状态的不断转移, 其特性主要使用转移概率来表示. HMM:认为模型的状态是不可观测的(hidden), 能 ...
- oc小总结
oc的一些总结 下面几个问题是oc中需要掌握的内容 1.如何掌握一个方法的方法名 2.一个对象调用一个autorelease,什么时候释放 3.字典和数组,集合都有什么特点 4.如何定义一个类 5.类 ...
- iOS学习笔记---oc语言第八天
属性 能在一定程度上简化代码,并且增强实例变量的访问安全性 属性的声明:使用@property声明属性 eg:@property NSSstring *name;相当于@interface中声明了两 ...
- db2 字符串转换 数字
今天使用聚合函数的时候 发现 varchar类型的是不可用的,所以呢就开始想办法解决 用到了转换函数cast(s.score as bigint) 然后有一个问题就是如果数据为空的话就会发生转换错误. ...
- SQL编写
//用户表,用户ID,用户名称create table t_user (user_id int,username varchar(20));//用户帐户表,用户ID,用户余额(单位分)create t ...
- C++ Primer : 第十二章 : 动态内存之shared_ptr与new的结合使用、智能指针异常
shared_ptr和new结合使用 一个shared_ptr默认初始化为一个空指针.我们也可以使用new返回的指针来初始化一个shared_ptr: shared_ptr<double> ...
- HashMap的笔记
size表示HashMap中存放KV的数量 capacity译为容量.capacity就是指HashMap中桶的数量.默认值为16.一般第一次扩容时会扩容到64,之后好像是2倍.总之,容量都是2的幂. ...
- c++函数模板---3
原创博客:转载请标明出处:http://www.cnblogs.com/zxouxuewei/ 模板从大体上,可以分为两种:函数模板和类模板.函数模板是算法库的基础,类模板是建立标准库容器和迭代器的基 ...
- php部分---对数据的多条件查询,批量删除
1.给多条件查询,添加条件 <h1>新闻信息查看</h1> <?php $tiaojian1=" 1=1"; $tiaojian2=" 1= ...
- POJ1459 Power Network(网络最大流)
Power Network Time Limit: 2000MS Memory Limit: 32768K Total S ...