Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Using awk to find and use the maximum value in column of data Post 302898192 by SriniShoo on Sunday 20th of April 2014 03:01:43 AM
Old 04-20-2014
make sure to give the file name twice at the end as given in the below code
Code:
awk 'NR == FNR {if(max < $3) {max = $3}; next} {$3 = $3 / max}1' sample.txt sample.txt

If you want the formatting of 3rd field,
Code:
awk 'NR == FNR {if(max < $3) {max = $3}; next} {$3 = $3 / max; printf "%d\t%d\t%.04f\n", $1, $2, $3}' sample.txt sample.txt

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find different column numbers among rows in data

I want to find the different column numbers among rows in a file. For example: A001 a b c d e ... N A002 a b c d e ... N A003 a b c d e ... N+1 A004 a b c d e ... N A005 a b c d e ... N+2 : : For most of the lines I will have N columns (say 1000 rows) in each line except the line 3... (5 Replies)
Discussion started by: AMBER
5 Replies

2. Shell Programming and Scripting

find expression with awk in only one column, and if it fits, print whole column

Hi. How do I find an expression with awk in only one column, and if it fits, then print that whole column. 1 apple oranges 2 bannanas pears 3 cats dogs 4 hesaid shesaid echo "which number:" read NUMBER (user inputs number 2 for this example) awk " /$NUMBER/ {field to search is field... (2 Replies)
Discussion started by: glev2005
2 Replies

3. Shell Programming and Scripting

for each different entry in column 1 extract maximum values from column 2 in unix/awk

Hello, I have 2 columns (1st column has multiple entries but the corresponding values in the column 2 may be the same or different.) however I want to extract unique values for each entry in column 1 by assigning the max value from column 2 SDF4 -0.211654 SDF4 0.978068 ... (1 Reply)
Discussion started by: Diya123
1 Replies

4. Homework & Coursework Questions

Find the Maximum value and average of a column

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am trying to complete a script which will allow me to find: a) reads a value from the keyboard. (ask the... (4 Replies)
Discussion started by: dstewie
4 Replies

5. Shell Programming and Scripting

AWK, Perl or Shell? Unique strings and their maximum values from 3 column data file

I have a file containing data like so: 2012-01-02 GREEN 4 2012-01-02 GREEN 6 2012-01-02 GREEN 7 2012-01-02 BLUE 4 2012-01-02 BLUE 3 2012-01-02 GREEN 4 2012-01-02 RED 4 2012-01-02 RED 8 2012-01-02 GREEN 4 2012-01-02 YELLOW 5 2012-01-02 YELLOW 2 I can't always predict what the... (4 Replies)
Discussion started by: rich@ardz
4 Replies

6. Programming

Find gaps in time data and replace missing time value and column 2 value by interpolation in awk

Dear all, I am kindly seeking assistance on the following issue. I am working with data that is sampled every 0.05 hours (that is 3 minutes intervals) here is a sample data from the file 5.00000 15.5030 5.05000 15.6680 5.10000 16.0100 5.15000 16.3450 5.20000 16.7120 5.25000... (4 Replies)
Discussion started by: malandisa
4 Replies

7. Shell Programming and Scripting

Find minimum and maximum values based on column with associative array

Hello, I need to find out the minimum and maximum values based on specific column, and then print out the entire row with the max value. Infile.txt: scf6 290173 290416 . + X_047241 T_00113118-1 scf6 290491 290957 . + X_047241 T_00113118-2 scf6 290898 290957 . + X_047241 T_00113119-3 scf6... (2 Replies)
Discussion started by: yifangt
2 Replies

8. Shell Programming and Scripting

awk to select lines with maximum value of each record based on column value

Hello, I want to get the maximum value of each record separated by empty line based on the 3rd column of each row within each record? Input: A1 chr5D 634 7 82 707 A2 chr5D 637 6 82 713 A3 chr5D 637 5 82 713 A4 chr5D 626 1 82 704... (4 Replies)
Discussion started by: yifangt
4 Replies

9. Shell Programming and Scripting

Get maximum per column from CSV file, based on date column

Hello everyone, I am using ksh on Solaris 10 and I'm gathering data in a CSV file that looks like this: 20170628-23:25:01,1,0,0,1,1,1,1,55,55,1 20170628-23:30:01,1,0,0,1,1,1,1,56,56,1 20170628-23:35:00,1,0,0,1,1,2,1,57,57,2 20170628-23:40:00,1,0,0,1,1,1,1,58,58,2... (6 Replies)
Discussion started by: ejianu
6 Replies

10. Shell Programming and Scripting

awk to find maximum and minimum from column and store in other column

Need your support for below. Please help to get required output If column 5 is INV then only consider column1 and take out duplicates/identical rows/values from column1 and then put minimum value of column6 in column7 and put maximum value in column 8 and then need to do subtract values of... (7 Replies)
Discussion started by: as7951
7 Replies
SASL-SAMPLE-CLIENT(8)					      System Manager's Manual					     SASL-SAMPLE-CLIENT(8)

NAME
sasl-sample-client -- Sample client program for demonstrating and testing SASL authentication. SYNOPSIS
sasl-sample-client [-b min=N,max=N] [-e ssf=N,id=ID] [-m MECH] [-f FLAGS] [-i local=IP,remote=IP] [-p PATH] [-s NAME] [-n FQDN] [-u ID] [-a ID] DESCRIPTION
This manual page documents briefly the sasl-sample-client command. This manual page was written for the Debian distribution because the original program does not have a manual page. sasl-sample-client is a program to demonstrate and test SASL authentication. It implements the client part, and the server part is avail- able as sasl-sample-server. OPTIONS
A summary of options is included below. -b Number of bits to use for encryption. min=N minimum number of bits to use (1 => integrity) max=N maximum number of bits to use -e Assume external encryption. ssf=N external mech provides N bits of encryption id=ID external mech provides authentication id ID -m Force use of MECH for security. -f Set security flags. noplain require security vs. passive attacks noactive require security vs. active attacks nodict require security vs. passive dictionary attacks forwardsec require forward secrecy maximum require all security flags passcred attempt to pass client credentials -i Set IP addresses (required by some mechs). local=IP;PORT set local address to IP, port PORT remote=IP;PORT set remote address to IP, port PORT -p Colon-separated search path for mechanisms. -r Realm to use. -s Service name passed to mechanisms. -n Server fully-qualified domain name. -u User (authorization) id to request. -a Id to authenticate as. -d Disable client-send-first. -l Enable server-send-last. SEE ALSO
For additional information, please see /usr/share/doc/sasl2-bin/testing.txt AUTHOR
This manual page was written by Fabian Fagerholm fabbe@debian.org for the Debian system (but may be used by others). Permission is granted to redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. SASL-SAMPLE-CLIENT(8)
All times are GMT -4. The time now is 11:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy