我有一个命令可以处理一个文本文件,计算所有出现的单词并像这样打印出来:
user@box $˜ magic-command-i-forgot | with grep | and awk | sort ./textfile.txt
66: the
54: and
32: I
16: unix
12: bash
5: internet
3: sh
1: GNU/Linux
Run Code Online (Sandbox Code Playgroud)
因此,它不是逐行搜索,而是逐词搜索,而且它会搜索所有单词,而不仅仅是 1 个单词。很久以前我在互联网上的某个地方找到了它,但我找不到或不记得它了。
sort ×1