转(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 ...
随机推荐
- u32 mac以及arp匹配
# Examples that match MAC (a big "thank you" to Julian Anastasov for this!): M0 through M5 ...
- Think Python - Chapter 16 - Classes and functions
16.1 TimeAs another example of a user-defined type, we’ll define a class called Time that records th ...
- raido 赋值第一次成功,然后就赋值不显示
$("#id").attr("checked",true); //显示出现问题,第一次成功 $("#id").prop("chec ...
- TextView所有属性
android:autoLink设置是否当文本为URL链接/email/电话号码/map时,文本显示为可点击的链接.可选值(none/web/email/phone/map/all) android: ...
- java List 排序 Collections.sort()
用Collections.sort方法对list排序有两种方法 第一种是list中的对象实现Comparable接口,如下: /** * 根据order对User排序 */ public class ...
- AndroidStudio用微信官方方法接入微信分享功能
转载请注明出处:http://www.cnblogs.com/wangoublog/p/5367950.html 现在微信的功能众所周知,用户量.影响力也是惊人,很多应用接入微信的功能已成为一种不可缺 ...
- c#---部分;把数组或者结构体存入集合里,然后再从集合中取出之后,输出;foreach既可以用到提取数组重点额数据,也可以提取集合中的数据(前提是集合中的元素是相同数据类型)
1.输入班级人数,统计每个人的姓名,性别,年龄:集合与数组 //Console.Write("请输入班级人数:"); //int a = int.Parse(Console.Rea ...
- activiti 中的签收与委托 操作
原文:http://my.oschina.net/acitiviti/blog/350957 先看看activiti中关于TASK的数据库表: 其中有两个字段:OWNER_,ASSIGNEE_ 这两个 ...
- ArrayList线程不安全
ArrayList线程不安全分析 http://wsmajunfeng.iteye.com/blog/1493941 一个 ArrayList ,在添加一个元素的时候,它可能会有两步来完成:1. ...
- nginx的HA集群及配置
一.服务器环境 master服务器: ip:192.168.11.155 系统环境:CentOS release 6.5 (Final) 内核版本:2.6.32-431.el6.x86_64 防火墙和 ...