1
所以,基本上我试图计算每个单词出现在厨师食谱文件上的出现次数。不正确的输出uniq -c
7-zip
ant
ant
ant
apache2
apache2
apache2
apache2
api-example-v1
api-products-v3
apt
apt
apt
ark
ark
ark
artifactory
artifactory
artifactory-wrapper
atp-cache-clear
所以它应该是一样简单“的uniq -c myfile.txt的”(该文件已经排序),但我遇到的问题是,当我这样做,我得到这样的输出:
1 7-zip
2 ant
1 ant
3 apache2
1 apache2
1 api-example-v1
1 api-products-v3
2 apt
1 apt
2 ark
1 ark
1 artifactory
1 artifactory
1 artifactory-wrapper
1 atp-cache-clear
1 atp-cache-clear
2 atpc-deployer
1 atpc-deployer
2 atpc-wrapper
1 atpc-wrapper
正如你所看到的输出是不正确的。例如,“方舟”应该只出现一次,计数为3.所有项目都是如此。
我已经做了这个没有问题与另一个文件和输出是正确的。
作为一个说明,我已经尝试过“cat -T myfile.txt”查看非打印字符,看看是否有什么东西在那里,我看不到但没有显示。
我还从文件的每一行中剥离了尾部和前导空格。
我还可能缺少什么?
$ cat -A wholething.txt |头-20 7-ZIP^M $ 蚂蚁$ 蚂蚁$ 蚂蚁^ M $ 的Apache2 $ 的Apache2 $ 的Apache2 $ 的Apache2^M $ API的例子-V1^M $ API产品-V3^M $ 容易$ 容易$ 容易^ M $ 方舟$ 方舟$ 方舟^ M $ artifactory的$ artifactory的^ M $ artifactory的-包装^ M $ ATP缓存清晰$ 什么一个傻瓜!非常感谢,我现在可以看到发生了什么。 –