## Find min.max value if matching columns found using AWK

 shell scripts Find min.max value if matching columns found using AWK
# 1
Find min.max value if matching columns found using AWK

Input_ File :
Desired output :
Explanation:

If ( \$2==\$4) then
Minimum value of \$1 and \$3 =becomes==>col1
Maximum value of \$1 and \$3 =becomes==> col3

If(\$1==\$3) then
Minimum value of \$2 and \$4 ==becomes==>col2
Maximum value of \$2 and \$4 ==becomes==>col4

Else
print as it is.
# 2
Quote:
Explanation:

If ( \$2==\$4) then
Minimum value of \$1 and \$3 =becomes==>col1
Maximum value of \$1 and \$3 =becomes==> col3

If(\$1==\$3) then
Minimum value of \$2 and \$4 ==becomes==>col2
Maximum value of \$2 and \$4 ==becomes==>col4

Else
print as it is.
The following line should solve your problem.
.. however I don't understand how you should get this output, can you elaborate Quote:
Desired output :
 danmero View Public Profile for danmero Find all posts by danmero
# 3
HI,

Thanks .

Its is simple that i need to check input file and i need to reduce the lines by two ways.

way1: checking column2 and column4 if it is equal, i will replace those line by single line with total 4 columns.

i.e ) column 1 contains min value
col3 contains max. value.
col 2 and col 4 is same

way2 : here as explained in the prev example.

It is actually reducing the records...

Hi, ur code is printing all the values... expected output is less lines as per the explained ways.

---------- Post updated at 11:53 AM ---------- Previous update was at 09:19 AM ----------

To be clear consider the below input_file

here other than first record, all other records are \$2 == \$4, then i can reduce those \$2==\$4 records to a single record.

Desired output
The desired output contains second line with Col1 is min value(-1) of \$2==\$4 rows and Col2(4) is max value of \$2==\$4 rows.
# 4

Last edited by danmero; 11-21-2011 at 10:17 PM.. Reason: Fix small error
 danmero View Public Profile for danmero Find all posts by danmero

## Find min and max time taken from a log file

You have a log file as attached in sample input with various operations and time taken by each of them. Write a script to find the min and max time taken for each operation. Sample output is attached. Sample Input is given as below: operation1,83621 operation2,72321 operation3,13288...

## How to get min and max values using awk?

Hi, I need your kind help to get min and max values from file based on value in \$5 . File1 SP12.3 stc 2240806 2240808 + ID1_N003 ID2_N003T0 SP12.3 sto 2241682 2241684 + ID1_N003 ID2_N003T0 SP12.3 XE 2239943 2240011 + ID1_N003 ID2_N003T0 SP12.3 XE 2240077 2241254 + ID1_N003 ...

## awk script to find min and max value

I need to find the max/min of columns 1 and 2 of a 2 column file what contains the special character ">". I know that this will find the max value of column 1. awk 'BEGIN {max = 0} {if (\$1>max) max=\$1} END {print max}' input.file But what if I needed to ignore special characters in the...

## Get the min avg and max with awk

aaa: 3 ms aaa: 2 ms aaa: 5 ms aaa: 10 ms .......... to get the 3 2 5 10 ...'s min avg and max something like min: 2 ms avg: 5 ms max: 10 ms

## [Solved] Print a line using a max and a min values of different columns

Hi guys, I already search on the forum but i can't solve this on my own. I have a lot of files like this: And i need to print the line with the maximum value in last column but if the value is the same (2 in this exemple for the 3 last lines) i need get the line with the minimum value in...

## to find min and max value for each column!

Hello Experts, I have got a txt files which has multiple columns, I want to get the max, min and diff (max-min) for each column in the same txt file. Example: cat file.txt a 1 4 b 2 5 c 3 6 I want ouput like: cat file.txt a 1 4 b 2 5 c 3 6 Max 3 6 Min 1 4 Diff 2 2 awk 'min=="" ||...

## How to find the average,min,max ,total count?

Hi , Below is my sample data,I have this 8 column(A,B,C,D,E,F,G,H) in csv file. A , B ,C ,D ,E ,F,G ,H 4141,127337,24,15,20,69,72.0,-3 4141,128864,24,15,20,65,66.0,-1 4141,910053,24,15,4,4,5.0,-1 4141,910383,24,15,22,3,4.0,-1 4141,496969,24,15,14,6,-24.0,-18...

## Awk search for max and min field values

hi, i have an awk script and I managed to figure out how to search the max value but Im having difficulty in searching for the min field value. BEGIN {FS=","; max=0} NF == 7 {if (max < \$6) max = \$6;} END { print man, min} where \$6 is the column of a field separated by a comma

## how to find min, max dates in a file

hello friends...:-) i need some help i have a file cantain like this Star1 ,NetWork,09/02/2008 Star1 ,NetWork,10/02/2008 Star1 ,NetWork,11/02/2008 Star2 ,NetWork,08/03/2008 Star2 ,NetWork,09/04/2008 Star2 ,NetWork,10/05/2008 i need to find out min, max dates the output look like...

## How to find whenther given value is in betwwen min and Max in unix shell scripting

Hi I wanted to write a shell script with an if condition Example MinValue=10 MaxValue=30 logvalue = some integer value that script reads from the command line arguement I wanted to check whether log value greater than or equal to10 and less than equal to 30 and proceed with the rest of...