top 10 highest and lowest percentile from a column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting top 10 highest and lowest percentile from a column
# 1  
Old 05-16-2012
top 10 highest and lowest percentile from a column

Hi, I want to extract the the top 10 and lowest 10 percentile for a column of values.

For example in column 2 for this file:

Code:
JOE   1 
JAY   5
JAM   6
JIL   8
JIB   4
JIH   3
JIG   2
JIT   7
JAM   9
MAR   10

The top 10 lowest will be:

Code:
JOE   1

and the top 10 highest will be:

Code:
MAR 10

If there is a quick way of doing this then it would be great

Thanks
# 2  
Old 05-16-2012
Take a look at the following post

I looked for the:
bottom of top 5 (since 10 seemed weird with only 10 records)
top 1

Code:
$ sort -k2n <sample9.txt | head -5 | tail -1
JAY   5

$ sort -k2n <sample9.txt | head -1
JOE   1

# 3  
Old 05-16-2012
You could use the following:

Code:
Highest
sort -rn -k2 file | head -n1

Lowest
sort -n -k2 file | head -n1

If you need more lines displayed just change the number in the head command (i.e. to display 10 lines use head -n10).

Hope this helps.
This User Gave Thanks to in2nix4life For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Print whole line with highest value from one column

Hi, I have a little issue right now. I have a file with 4 columns test0000002,10030010330,c_,218 test0000002,10030010330,d_,202 test0000002,10030010330,b_,193 test0000002,10030010020,c_,178 test0000002,10030010020,b_,170 test0000002,10030010330,a_,166 test0000002,10030010020,a_,151... (2 Replies)
Discussion started by: Ebk
2 Replies

2. Shell Programming and Scripting

Calculate 5th percentile based on another column

I would like to have some help in calculating 5th percentile value of column 2 for each site, the input is like below:site val1 val2 002 10 25.3 002 20 25.3 002 30 25.3 002 40 20 002 50 20 002 60 20 002 70 20 002 80 30 002 90 30 002 100 30 002 120 30 003 20 30.3 003 20 30.3 003 30 20... (2 Replies)
Discussion started by: wuhuai
2 Replies

3. Shell Programming and Scripting

Sort from highest to lowest number

Hi Guys, I am looking for a way to sort the output below from the "Inuse" count from Highest to Lowest. Is it possible? Thanks in advance. user1 0.12 0.06 0 0.12 User Inuse Pin Pgsp Virtual Unit:... (4 Replies)
Discussion started by: jaapar
4 Replies

4. UNIX for Dummies Questions & Answers

Awk, highest and lowest value of a column

Hi again! I am still impressed how fast I get a solution for my topic "average specific column value awk" yesterday. The associative arrays in awk work fine for me! But now I have another question for the same project. Now I have a list like this 1 -0.1 1 0 1 0.1 2 0 2 0.2 2 -0.2 How... (10 Replies)
Discussion started by: bjoern456
10 Replies

5. Shell Programming and Scripting

Find lines with matching column 1 value, retain only the one with highest value in column 2

I have a file like: I would like to find lines lines with duplicate values in column 1, and retain only one based on two conditions: 1) keep line with highest value in column 3, 2) if column 3 values are equal, retain the line with the highest value in column 4. Desired output: I was able to... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

6. Shell Programming and Scripting

Selecting lowest and highest values in columns 1 and 2, based on subsets in column 3

Hi, I have a file with the following columns: 361459 447394 CHL1 290282 290282 CHL1 361459 447394 CHL1 361459 447394 CHL1 178352861 178363529 AGA 178352861 178363529 AGA 178363657 178363657 AGA Essentially, using CHL1 as an example. For any line that has CHL1 in... (2 Replies)
Discussion started by: hubleo
2 Replies

7. UNIX for Dummies Questions & Answers

Print line with highest value from one column

Hi everyone, This is my first post, but I have already received a lot of help from the forums in the past. Thanks! I've searched the forums and my question is very similar to an earlier post entitled "Printing highest value from one column", which I am apparently not yet allowed to post a... (3 Replies)
Discussion started by: dliving3
3 Replies

8. UNIX for Dummies Questions & Answers

Print line with highest value from one column

Hi everyone, This is my first post, but I have already received a lot of help from the forums in the past. Thanks! I've searched the forums and my question is very similar to an earlier post entitled "Printing highest value from one column", which I am apparently not yet allowed to post a... (1 Reply)
Discussion started by: dliving3
1 Replies

9. UNIX for Dummies Questions & Answers

Printing highest value from one column

Hi, I have a file that looks like this: s6 98 s6 91 s6 56 s5 32 s5 10 s5 4 So what I want to do is print only the highest value for each value in the column: So the file will look like this: s6 98 s5 32 Thanks (4 Replies)
Discussion started by: phil_heath
4 Replies

10. Shell Programming and Scripting

Perl ? - How to find and print the lowest and highest numbers punched in by the user?

. . . . . . (3 Replies)
Discussion started by: some124one
3 Replies
Login or Register to Ask a Question