我有一个像这样的输入文件
John completed his graduation John is working for an IT industry Thomas completed his graduation John completed his graduation Thomas is working for an IT industry Thomas is working for an IT industry
我想要一个像这样的输出
John word has 2 Graduations Thomas word has 2 IT industry
任何人都可以帮助我吗
答案 0 :(得分:0)
答案 1 :(得分:0)
也许你可以做这样的事情并努力用你的选择替换这些词
sort file | uniq -c | sort -k2,2 -k1,1r | awk '!a[$2]++{print $2, "word has", $1, $NF}'
John word has 2 graduation
Thomas word has 2 industry
对文件进行排序,查找每个文件的计数,为每行记录最高计数并打印。