Unique entry set in the first column of all csv files under directory

561 views Asked by At

I have a list of comma separated files under the directory. There are no headers, and unfortunately they are not even the same length for each row.

I want to find the unique entry in the first column across all files.

What's the quickest way of doing it in shell programming?

awk -F "," '{print $1}' *.txt | uniq

seems to only get uniq entries of each files. I want all files.

1

There are 1 answers

4
karakfa On BEST ANSWER

Shortest is still using awk (this will print the row)

awk -F, '!a[$1]++' *.txt

to get just the first field

awk -F, '!a[$1]++ {print $1}' *.txt