【发布时间】:2015-01-12 17:27:15
【问题描述】:
我正在使用 bash 命令对一些结果进行排序。我的file_of_counts基本上是这样的
23 (some text),(1 2 3 4 1)
95 (some text),(1 2 3 3 5)
9 (some text),(1 2 3 5 5)
10 (some text),(1 2 3 2 5)
10 (some text),(1 2 3 4 4)
45 (some text),(1 2 3 4 2)
我做到了这一点
cat myfile | grep some_term | uniq -c > file_of_counts
所以我找到了带有关键字“some_term”的行,然后找到了唯一的行,其中uniq -c 还给出了每个唯一行的计数,这基本上已经在上面的示例file_of_counts 中进行了描述。
如您所见,每一行都有一些前导空格。由于某种原因,我无法制作
cat file_of_counts | sort
工作,或者更确切地说,它不会给我正确的答案。我必须在前导空白或其他东西上遗漏一些明显的东西。帮助表示赞赏。
【问题讨论】:
标签: bash sorting unix grep uniq