2

I am trying to print the unique entries in a column of a .csv file. For this, I tried the following:

awk -F "," '{print $6}' dataCoarse.csv | uniq -u

which just prints the 6th column as it is. There are still duplicate entries. How can I print only the unique lines?

Edit: I think I need to remove the blank spaces preceding or trailing any character on each line, or have uniq somehow disregard them. How can I do this?

1 Answers1

3

I had this problem too! Check out this solution to a similar problem. Basically, you want to pipe your data to sort first, as uniq only counts consecutive instances of your data as duplicate.

awk -F "," '{print $6}' dataCoarse.csv | sort -u should give you the output you're looking for.