Sponsored Content
Top Forums Shell Programming and Scripting Get the average from column, and eliminate the duplicate values. Post 302889746 by RudiC on Sunday 23rd of February 2014 04:39:28 PM
Old 02-23-2014
You did not answer Don Cragun's question about what you had tried... and your desired output does not match your specification (first line's avarage x is wrong, and the last line is missing). However, try also
Code:
awk     '                       {A = substr ($0,11,17); B = substr ($0, 57, 8); C = substr ($0, 66, 9)}
         A != OA && NR > 1      {printf "%s%6.1f %6.1f%s\n", substr(D,1,56), SUM1/CNT, SUM2/CNT, substr(D,75); CNT=0; SUM1=SUM2=""}
         END                    {printf "%s%6.1f %6.1f%s\n", substr(D,1,56), SUM1/CNT, SUM2/CNT, substr(D,75); CNT=0; SUM1=SUM2=""}
                                {OA = A; D=$0; SUM1+=B; SUM2+=C; CNT++}
        ' file
A         25235.0 21449.012 6 75   1   4163171 79 37 21 865929.2 1931456.8  23.1   897 102 1              P    1T N/A 54000038 0.81383
A         25015.0 20921.01310 75   2  -4163868 76 36 19 857250.6 1920090.0 -22.2   188 103 1              P    1T N/A 54000056 0.81382
A         25233.0 21449.012 6 75   1   3122671 78 44 28 865967.4 1931414.2  23.0   896 102 1                   1T N/A 54000135 0.81383
A         25013.0 20921.01310 75   2  -4122770 77 42 20 857275.9 1920046.1 -22.2   187 103 1              P    1T N/A 54000153 0.81382
A         25011.0 20921.01310 75   2  -4132669 75 38 21 857301.0 1920001.9 -22.1   186 103 1              P    1T N/A 54000235 0.81382
A         25231.0 21449.012 6 75   1  -3132571 80 40 26 865980.5 1931360.2  23.0   964 102 1                   1T N/A 54000253 0.81382


Last edited by RudiC; 02-23-2014 at 05:45 PM..
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find and replace duplicate column values in a row

I have file which as 12 columns and values like this 1,2,3,4,5 a,b,c,d,e b,c,a,e,f a,b,e,a,h if you see the first column has duplicate values, I need to identify (print it to console) the duplicate value (which is 'a') and also remove duplicate values like below. I could be in two... (5 Replies)
Discussion started by: nuthalapati
5 Replies

2. Shell Programming and Scripting

Average values in a column based on range

Hi i have data with two columns like below. I want to find average of column values like if the value in column 2 is between 0-250000 the average of column 1 is some xx and average of column2 is ww then if value is 250001-5000000 average of column 1 is yy and average of column 2 is zz. And my... (5 Replies)
Discussion started by: bhargavpbk88
5 Replies

3. UNIX for Dummies Questions & Answers

[SOLVED] remove lines that have duplicate values in column two

Hi, I've got a file that I'd like to uniquely sort based on column 2 (values in column 2 begin with "comp"). I tried sort -t -nuk2,3 file.txtBut got: sort: multi-character tab `-nuk2,3' "man sort" did not help me out Any pointers? Input: Output: (5 Replies)
Discussion started by: pathunkathunk
5 Replies

4. Shell Programming and Scripting

Average of columns with values of other column with same name

I have a lot of input files that have the following form: Sample Cq Sample Cq Sample Cq Sample Cq Sample Cq 1WBIN 23.45 1WBIN 23.45 1CVSIN 23.96 1CVSIN 23.14 S1 31.37 1WBIN 23.53 1WBIN 23.53 1CVSIN 23.81 1CVSIN 23.24 S1 31.49 1WBIN 24.55 1WBIN 24.55 1CVSIN 23.86 1CVSIN 23.24 S1 31.74 ... (3 Replies)
Discussion started by: isildur1234
3 Replies

5. Shell Programming and Scripting

Average values of duplicate rows

I have this file input.txt. I want to take average column-wise for the rows having duplicate gene names. Gene Sample_1 Sample_2 Sample_3 gene_A 2 4 5 gene_B 1 2 3 gene_A 0 5 7 gene_B 4 5 6 gene_A 11 12 13 gene_C 2 3 4 Desired output: gene_A 4.3 7 8.3 gene_B 2.5 3.5 4.5 gene_C 2 3 4... (6 Replies)
Discussion started by: Sanchari
6 Replies

6. Shell Programming and Scripting

Identify duplicate values at first column in csv file

Input 1,ABCD,no 2,system,yes 3,ABCD,yes 4,XYZ,no 5,XYZ,yes 6,pc,noCode used to find duplicate with regard to 2nd column awk 'NR == 1 {p=$2; next} p == $2 { print "Line" NR "$2 is duplicated"} {p=$2}' FS="," ./input.csv Now is there a wise way to de-duplicate the entire line (remove... (4 Replies)
Discussion started by: deadyetagain
4 Replies

7. Shell Programming and Scripting

Filter file to remove duplicate values in first column

Hello, I have a script that is generating a tab delimited output file. num Name PCA_A1 PCA_A2 PCA_A3 0 compound_00 -3.5054 -1.1207 -2.4372 1 compound_01 -2.2641 0.4287 -1.6120 3 compound_03 -1.3053 1.8495 ... (3 Replies)
Discussion started by: LMHmedchem
3 Replies

8. Shell Programming and Scripting

Remove duplicate values in a column(not in the file)

Hi Gurus, I have a file(weblog) as below abc|xyz|123|agentcode=sample code abcdeeess,agentcode=sample code abcdeeess,agentcode=sample code abcdeeess|agentadd=abcd stereet 23343,agentadd=abcd stereet 23343 sss|wwq|999|agentcode=sample1 code wqwdeeess,gentcode=sample1 code... (4 Replies)
Discussion started by: ratheeshjulk
4 Replies

9. Shell Programming and Scripting

Find duplicate values in specific column and delete all the duplicate values

Dear folks I have a map file of around 54K lines and some of the values in the second column have the same value and I want to find them and delete all of the same values. I looked over duplicate commands but my case is not to keep one of the duplicate values. I want to remove all of the same... (4 Replies)
Discussion started by: sajmar
4 Replies

10. UNIX for Beginners Questions & Answers

Find lines with duplicate values in a particular column

I have a file with 5 columns. I want to pull out all records where the value in column 4 is not unique. For example in the sample below, I would want it to print out all lines except for the last two. 40991764 2419 724 47182 Cand A 40992936 3591 724 47182 Cand B 40993016 3671 724 47182 Cand C... (5 Replies)
Discussion started by: kaktus
5 Replies
indicator(1F)							   FMLI Commands						     indicator(1F)

NAME
indicator - display application specific alarms and/or the "working" indicator SYNOPSIS
indicator [ -b [n]] [-c column] [-l length] [-o] [-w] [string...] DESCRIPTION
The indicator function displays application specific alarms or the "working" indicator, or both, on the FMLI banner line. The argument string is a string to be displayed on the banner line, and should always be the last argument given. Note that string is not automatically cleared from the banner line. OPTIONS
-bn The -b option rings the terminal bell n times, where n is an integer from 1 to 10. The default value is 1. If the terminal has no bell, the screen is flashed instead, if possible. -c column The -c option defines the column of the banner line at which to start the indicator string. The argument column must be an integer from 0 to DISPLAYW-1. If the -c option is not used, column defaults to 0 . -l length The -l option defines the maximum length of the string displayed. If string is longer than length characters, it will be truncated. The argument length must be an integer from 1 to DISPLAYW. If the -l option is not used, length defaults to DIS- PLAYW. Note that if string doesn't fit it will be truncated. -o The -o option causes indicator to duplicate its output to stdout . -w The -w option turns on the "working" indicator. EXAMPLES
Example 1: A sample output of the indicator command. When the value entered in a form field is invalid, the following use of indicator will ring the bell three times and display the word WRONG starting at column 1 of the banner line. invalidmsg=`indicator -b 3 -c 1 "WRONG"` To clear the indicator after telling the user the entry is wrong: invalidmsg=`indicator -b 9 -c 1 "WRONG"; sleep 3; indicator -c 1 " "` In this example the value of invalidmsg (in this case the default value Input is not valid), still appears on the FMLI message line. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) SunOS 5.10 5 Jul 1990 indicator(1F)
All times are GMT -4. The time now is 05:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy