Shell脚本读取CSV中的两列,并计算第1列中每个唯一值在第2列中的uniq值
Shell脚本读取CSV中的两列,并计算第1列中每个唯一值在第2列中的唯一值 我有一张看起来像Shell脚本读取CSV中的两列,并计算第1列中每个唯一值在第2列中的uniq值,shell,csv,Shell,Csv,Shell脚本读取CSV中的两列,并计算第1列中每个唯一值在第2列中的唯一值 我有一张看起来像 1 a 2 a 3 b 3 c 2 a 2 f 2 a 1 d 我需要的输出是: 1 2 2 3 3 2 我尝试了上述方法,但我做错了什么。这里是shell脚本的新手。为什么23而不是22?awk-F'\t'{!s[$1fs$2]+&&c[$1]+}END{用于(c中的i)打印i,c[i]}表。tsv cut -f 1,2 | sort | uniq -c | so
1 a
2 a
3 b
3 c
2 a
2 f
2 a
1 d
我需要的输出是:
1 2
2 3
3 2
我尝试了上述方法,但我做错了什么。这里是shell脚本的新手。为什么
23
而不是22
?awk-F'\t'{!s[$1fs$2]+&&c[$1]+}END{用于(c中的i)打印i,c[i]}表。tsv
cut -f 1,2 | sort | uniq -c | sort