Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

finding unique values in a data file

Tags:

I can do this in python but I was wondering if I could do this in Linux

I have a file like this

name1 text text 123432re text name2 text text 12344qp text name3 text text 134234ts text 

I want to find all the different types of values in the 3rd column by a particular username lets say name 1.

grep name1 filename gives me all the lines, but there must be some way to just list all the different type of values? (I don't want to display duplicate values for the same username)

like image 769
Illusionist Avatar asked Aug 05 '11 03:08

Illusionist


People also ask

How do you find unique values of data?

In Excel, there are several ways to filter for unique values—or remove duplicate values: To filter for unique values, click Data > Sort & Filter > Advanced. To remove duplicate values, click Data > Data Tools > Remove Duplicates.

How do I get a list of unique values from a table?

The SQL SELECT DISTINCT Statement The SELECT DISTINCT statement is used to return only distinct (different) values. Inside a table, a column often contains many duplicate values; and sometimes you only want to list the different (distinct) values.


1 Answers

grep name1 filename | cut -d ' ' -f 4 | sort -u 

This will find all lines that have name1, then get just the fourth column of data and show only unique values.

like image 59
Mike Mertsock Avatar answered Sep 29 '22 09:09

Mike Mertsock