1、文章

Newly-added concrete barriers and steel posts can be seen alongside the bike path, and more will be installed in the coming months across the city, as the NYPD has promised.

2、操作过程:

2.1 将文中的换行符替换成空格 tr '\n' ' ' <a.txt 2.2 将空格去除 sed 's# ##g' 2.3 将单词拆分成单个字母并换行 grep -o '\w' 2.4 单词出现的频率进行倒序 sort|uniq -c|sort -rn

3、最后的执行语句为:(此语句是将区分大小写的) tr '\n' ' ' <a.txt|sed 's# ##g'|grep -o '\w' |sort|uniq -c |sort -rn

20 e 13 s 11 t 11 a 10 n 9 i 8 o 8 d 7 r 7 l 7 h 6 c 4 m 4 b 3 p 2 y 2 w 2 N 2 g 1 Y 1 P 1 k 1 D

4、tr '\n' ' ' <a.txt|awk '{print toupper($0)}'|sed 's# ##g'|grep -o '\w' |sort|uniq -c |sort -rn > 20 e > 13 s > 12 n > 11 t > 11 a > 9 i > 9 d > 8 o > 7 r > 7 l > 7 h > 6 c > 4 p > 4 m > 4 b > 3 y > 2 w > 2 g > 1 k > tr '\n' ' ' <a.txt|sed 's# ##g'|grep -o '\w' |sort|uniq -ic |sort -rn(忽略大小写)

5、大小写转换:

awk '{print toupper($0)}' <a.txt (转化为大写) awk '{print tolower($0)}' <a.txt (转化为小写)

================================================================= 按照单词出现的频率进行排序 sed 's#[,.]##g'<a.txt |tr ' ' '\n'|sort|uniq -c|sort -rn