## awk second largest, third largest value

awk second largest, third largest value
# 8
09-14-2011
i'm having a hard time understanding the !second{print \$0;second=\$2;}\$2<second{print \$0;exit;}' line
.

I want to understand it to tailor it to find 3rd largest maxes with difference greater than 5 (as used in second largest logic), 4th largsest maxes with that same difference, 5th largest, etc. etc.

Thanks for the help so far. I am in unfamiliar territories with awk here.
 theawknewbie View Public Profile for theawknewbie Find all posts by theawknewbie
# 9
09-14-2011
hi, see this example:
say max=100

if you want the 2nd largest number is 80 , then the next smaller should be the 3rd largest (79) and you don't have to compare 3rd and max, to check if the difference is > 5.

or you want to ensure that difference between 2nd and 3rd > 5?

---------- Post updated at 17:16 ---------- Previous update was at 17:05 ----------

regarding this line:
if a variable is not assigned any value, it returns false in a boolean check. so "!second" means "if variable <second> has not been set, then do {block}"
 sk1418 View Public Profile for sk1418 Find all posts by sk1418
# 10
09-14-2011
yes, i want to ensure between 2nd and 3rd is > 5, and 3rd and 4th is > 5, 4th and 5th > 5, etc. etc.

thanks
 theawknewbie View Public Profile for theawknewbie Find all posts by theawknewbie
# 11
09-14-2011
Ok.
don't say etc. etc. how many "largest" numbers do you want?
2nd -- ?th
or all as long as possible?
 sk1418 View Public Profile for sk1418 Find all posts by sk1418
# 12
09-14-2011
up to 8 largest, with the differences still there (i.e. difference greater than 5 between the previous largest).

thanks for helping me out, I've never gone this far in awk before. But I am learning.
 theawknewbie View Public Profile for theawknewbie Find all posts by theawknewbie
# 13
09-14-2011
here I made an example, hope that it helps:

This User Gave Thanks to sk1418 For This Post:
 sk1418 View Public Profile for sk1418 Find all posts by sk1418
# 14
09-14-2011
thanks this is perfect! thanks for stickin it out with me!
 theawknewbie View Public Profile for theawknewbie Find all posts by theawknewbie

## awk to combine all matching fields in input but only print line with largest value in specific field

In the below I am trying to use awk to match all the \$13 values in input, which is tab-delimited, that are in \$1 of gene which is just a single column of text. However only the line with the greatest \$9 value in input needs to be printed. So in the example below all the MECP2 and LTBP1...

## Largest number in array. Help!

I need to calculate the biggest number in array size n. Example: Users enter: 1 7 4 9 The biggest number is : 9 Simple but I'm really new on this on Shell/Bash! Anything will be helpful! Thanks! #!/bin/bash printf "\tEnter a list of numbers, with spaces: " read -a ARRAY BIG=\$1...

## Printf awk: argument to adjust automatically width to the largest value

Hi ! Here is an example of a tab-delimited file with variable width values in field 2 (space separated values). As the real file contains lot of lines, I can adjust manually the width to the largest value in field 2. Does it exist an argument to do it automatically? input.tab:...

## Help with keep the largest record in file

Input file US Score 10 UK Ball 20 AS Score 50 AK Ball 10 PZ Ballon 50 PA Score 70 WT Data 10 . . Desired output file UK Ball 20 PZ Ballon 50 PA Score 70 WT Data 10 . .

## AWK (how) to get smallest/largest nr of ls -la

Hey, This is a long-shot however, I am stuck with the following problem: I have the output from ls -la, and I want to sort some of that data out by using AWK to filter it. ls -la | awk -f scriptname.awk Input: For example: drwxr-xr-x 3 user users 4096 2010-03-14 20:15 bin/...

## largest file

My directory only contains files..no sub directories..I want to know about the largest file in directory..Largest in terms of size..And what if I want to know about first 3 largest files.. Is it possible to know largest file in terms of its filename??

## Find largest files

Hello, i am on linux 2.6.13-1.1526_FC4smp , and i would be very greatfull if someone could help to find the largest files on that server. I know i can find files with find command or list them with ls , but is there a way that i could list let's say 10 biggest files on server ? :o

## largest field , awk , help

Hi All, My file is like this: \$ cat max.txt abcd:1982:a efghij:1980:e klmn:1923:k opqrst:1982:o I have to find out the largest first field and the corresponding line. i.e Output required: efghij efghij:1980:e opqrst opqrst:1982:o HTH, jkl_jkl

## largest value from within a file

hi, i am having a file that looks like this : myhome111 oper 11 myhome333 oper 19 ... how can i get the largest value from this file ..in this example i am consiering 19 as the largest value.. how can i do that.. as this file is having other numbers also within it like 111, 333...

## find largest file

Hi, 1)I have XX directory and have lot of files ,I want to find largest file in that directory 2)how calculate the size of file in MB. Thanks, Mohan