• Tools
  • Articles
  • Q&A
  • Login
0 0

如何计算文件中第一列不同值的个数?


例如


 aaa   999
aaa   111
aaa   333
bbb   888
bbb   000
ccc   111

要得出这种结果


 aaa 3
bbb 2
ccc 1

shell bash

11 years, 4 months ago
触手伸遍全世界

触手伸遍全世界


share
触手伸遍全世界 11 years, 4 months ago

Answers

0

 < file.txt cut -d ' ' -f 1 | sort | uniq -c | awk '{ print $2 " " $1 }'

answered 11 years, 4 months ago
触手伸遍全世界

Reafves


share
Reafves answered 11 years, 4 months ago

Your Answer

Ask Question
Related questions

bash脚本使用相对目录的问题

如何在iterm2上高亮指定的关键字, 比如: error, warning这些, 以前在Se...

怎样遍历移除项目中的所有 .pyc 文件

在terminal中打开的程序如何保证terminal被关闭后进程不受影响?

老是记不住 .tar.gz 的解压命令,求解脱

Bash脚本怎么实现在使用cd命令进入任意目录时自动执行?