我很抱歉这个非常棒的问题,但我对bash编程很新(几天前开始).基本上我想要做的是保留一个文件与另一个文件的所有单词出现
我知道我可以这样做:
sort | uniq -c | sort
Run Code Online (Sandbox Code Playgroud)
事情是,之后我想要第二个文件,再次计算出现次数并更新第一个.我拿第三个文件后依此类推.
我现在正在做什么没有任何问题(我正在使用grep,sed和awk),但它看起来很慢.
我很确定只有一个命令左右有一个非常有效的方法,使用uniq,但我无法弄清楚.
你能以正确的方式引导我吗?
我也粘贴了我写的代码:
#!/bin/bash
# count the number of word occurrences from a file and writes to another file #
# the words are listed from the most frequent to the less one #
touch .check # used to check the occurrances. Temporary file
touch distribution.txt # final file with all the occurrences calculated
page=$1 # contains the file I'm …Run Code Online (Sandbox Code Playgroud)