shell脚本,按字母出现频率降序排序。
[root@localhost oldboy]# cat file
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
[root@localhost oldboy]# cat .sh
#!/bin/bash
cat file|
while read line
do
for i in `seq ${#line}`
do
a=`echo $line|cut -c $i`
echo "$a" >> zimu.txt
done
done cat zimu.txt|sed -r 's/[ \t]+//g'|grep -v ^$|sort|uniq -c |sort -nr
[root@localhost oldboy]# bash .sh
s
e
o
t
n
i
r
a
u
p
d
m
l
c
f
q
h
b
w
v
P
j
g
.
,
[root@localhost oldboy]#
[root@localhost oldboy]# cat file|awk 'BEGIN{FS=""}{for(i=1;i<=NF;i++){if($i!=" "){a[$i]++}}}END{for(i in a){print i,a[i]}}'|sort -nr -k
s
e
o
t
n
i
r
a
u
p
d
m
l
c
f
q
h
b
w
v
P
j
g
.
,
[root@localhost oldboy]#
shell脚本,按字母出现频率降序排序。的更多相关文章
- 用shell处理以下内容 1、按单词出现频率降序排序! 2、按字母出现频率降序排序! the squid project provides a number of resources toassist users design,implement and support squid installations. Please browsethe documentation and support
此题目有多种解法,sed.awk.tr等等,都可以解决此题,命令运用灵活多变. 编写shell脚本no_20.sh 解法1: #!/bin/bash ###-------------CopyRight ...
- shell脚本,按单词出现频率降序排序。
[root@localhost oldboy]# cat file the squid project provides a number of resources toassist users de ...
- 自定义Map.Entry的Comperator实现字符频率降序排序
leetCode (#451,middle) java实现 class Solution { public String frequencySort(String s) { Map<Charac ...
- java算法面试题:有一个字符串,其中包含中文字符、英文字符和数字字符,请统计和打印出各个字符的个数 按值的降序排序,如果值相同则按键值的字母顺序
package com.swift; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; publi ...
- 怎么实现元素ol的降序排序显示
首先介绍一下什么是ol元素.这里直接引用MDN里面的定义:The HTML <ol> Element (or HTML Ordered List Element) represents a ...
- c++ sort降序排序
sort是c++ STL中提供的一个函数模板,可以用来对多种类型进行排序. 默认是升序排序.它有两种使用方法: default (1) template <class RandomAccessI ...
- 现在输入 n 个数字, 以逗号, 分开; 然后可选择升或者 降序排序;
/* 现在输入 n 个数字, 以逗号, 分开: 然后可选择升或者 降序排序: */ import java.util.*; public class bycomma{ public static St ...
- java数组降序排序之冒泡排序
import java.util.Arrays;//必须加载 class Demo{ public static void main(String []args){ int[] arr={3,54,4 ...
- 通过orderby关键字,LINQ可以实现升序和降序排序。LINQ还支持次要排序。
通过orderby关键字,LINQ可以实现升序和降序排序.LINQ还支持次要排序. LINQ默认的排序是升序排序,如果你想使用降序排序,就要使用descending关键字. static void M ...
随机推荐
- 51nod 1051【基础】
思路: 找题4级做做...然后找了题最水的.. = =感动...居然是一下子[记]得了做法... dp一下,枚举列的起点和终点,然后求和这一段,然后对这一大列就是求个最大字段和: #include & ...
- 2016 Noip提高组
2557. [NOIP2016]天天爱跑步 ★★☆ 输入文件:runninga.in 输出文件:runninga.out 简单对比时间限制:2 s 内存限制:512 MB [题目描述] ...
- sql数据库查询结果字段包含换行符导致复制到Excel发生错位问题的解决
问题描述:在工作过程中,有时会遇到这样的问题,写好sql查询语句在数据库中查询数据,看到行数(比如说是1000行),但是把查询结果复制到Excel里面,却发生了行列错位问题,而导致Excel里面的行数 ...
- assembly x86(nasm)选择排序
有一个首地址为NUM的N字无序无符号整数数组,编制程序采用选择排序法使该数组中的数按照从小到大的次序排序输出. 选择排序: data segment message db 'This is a pro ...
- Sublime Text 报“Pylinter could not automatically determined the path to lint.py
Pylinter could not automatically determined the path to lint.py. please provide one in the settings ...
- BOM主要对象属性方法总结
BOM window对象 浏览器实例,全局对象 1.窗口位置: screenTop,screenLeft(screenX,screenY):窗口相对于屏幕左边和上边的位置 moveTo(x,y):将窗 ...
- 大数加法 HDU 1002
#include <iostream> #include <cstring> #include <string> #include <cstdio> # ...
- [coci2015-2016 coii] Palinilap【字符串 哈希】
传送门:http://www.hsin.hr/coci/archive/2015_2016/ 进去之后点底下的那个.顺带说一句,题目既不是一个英文单词,也不是克罗地亚单词,估计只是从回文串的英文单词p ...
- NOI2012 D2T1扩展欧几里得
#include <bits/stdc++.h> using namespace std; #define ll long long ll extgcd(ll a,ll b,ll & ...
- oracle dual是个什么表
这几天一直在研究oracle,常常会用到dual这个系统表,dual表到底是一个什么表?带着疑问查了百度了一下,现在总结一下:DUAL是Oracle与数据字典一起自动创建的一个表,它只有一列:DUMM ...