How to count number of unique values of a field in a tab-delimited text file?

前端 未结 7 711
滥情空心
滥情空心 2020-12-23 14:21

I have a text file with a large amount of data which is tab delimited. I want to have a look at the data such that I can see the unique values in a column. For example,

7条回答
  •  梦毁少年i
    2020-12-23 14:40

    You can use awk, sort & uniq to do this, for example to list all the unique values in the first column

    awk < test.txt '{print $1}' | sort | uniq
    

    As posted elsewhere, if you want to count the number of instances of something you can pipe the unique list into wc -l

提交回复
热议问题