分享一个有趣的shell脚本--单词及字母去重排序案例
概述
今天主要分享一个用shell脚本来实现单词及字母去重排序案例,下面一起来看下吧~
需求
1、按单词出现频率降序排序!
2、按字母出现频率降序排序!
相关文本:
the squid project provides a number ofresources to assist users design implement and support squid installations. Please browse the documentation and support sections for more infomation byoldboy training
实现脚本:
#!/bin/bash ################################################ # File Name: abc.sh ################################################ a="the squid project provides a number ofresources to assist users design implement and support squid installations.Please browse the documentation and support sections for more infomation byoldboy training" echo "按单词出现频率降序排序!" for i in $a do echo $i done|\ sort |uniq -c|sort -nk1 -r echo "按字母出现频率降序排序!" echo $a |grep -o "[a-z]" |sort|uniq -c |sort -nk1 -r
执行结果:
觉得有用的朋友多帮忙转发哦!后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下~
相关推荐
Clairezz 2020-05-17
mingyunxiaohai 2020-05-10
Airuio 2020-04-25
bnmcvzx 2020-04-22
yaohustiAC 2020-03-04
ITxiaobaibai 2020-01-02
striver0 2011-04-16
happinessaflower 2011-04-14
sjyttkl 2017-08-08
JasonYeung 2019-07-12
Hannah 2019-07-06
Clairezz 2019-07-01
xiaomiaomi 2019-06-28
sunbrother 2019-06-28
陶赫Qt开发学习 2013-05-23
代码之神 2019-06-21