Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Taking the average of two columns and printing it on a new column Post 302677075 by evelibertine on Wednesday 25th of July 2012 01:50:34 PM
Old 07-25-2012
How would I go about altering the code if there are more than 2 files?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help in extracting multiple files and taking average at same time

Hi, I have 20 files which have respective 50 lines with different values. I would like to process each line of the 50 lines in these 20 files one at a time and do an average of 3rd field ($3) of these 20 files. This will be output to an output file. Instead of using join to generate whole... (8 Replies)
Discussion started by: ahjiefreak
8 Replies

2. UNIX for Dummies Questions & Answers

Comparing the 2nd column in two different files and printing corresponding 9th columns in new file

Dear Gurus, I am very new to UNIX. I appreciate your help to manage my files. I have 16 files with equal number of columns in it. Each file has 9 columns separated by space. I need to compare the values in the second column of first file and obtain the corresponding value in the 9th column... (12 Replies)
Discussion started by: Unilearn
12 Replies

3. UNIX for Dummies Questions & Answers

Taking a average of a column of numbers

Hey all, I am relatively poor at programming and unfortunately don't have time to read about programming at this current moment. I wanted to be able to run a simple command to read a column of numbers in a file and give me the average of those numbers. In addition if I could specify the... (2 Replies)
Discussion started by: Leonidsg
2 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

Calculate the average of a column based on the value of another column

Hi, I would like to calculate the average of column 'y' based on the value of column 'pos'. For example, here is file1 id pos y c 11 1 220 aa 11 4333 207 f 11 5333 112 ee 11 11116 305 e 11 11117 310 r 11 22228 781 gg 11 ... (2 Replies)
Discussion started by: jackken007
2 Replies

6. Shell Programming and Scripting

Cannot get the correct ans. Using awk in taking average

Hi all, I think so I’m getting the result is wrong, while using following awk commend, colval=$(awk 'FNR>1 && NR==FNR{a=$4;next;} FNR>1 {a+=$4; print $2"\t"a/3}' filename_f.tsv filename_f2.tsv filename_f3.tsv) echo $colval >> Result.tsv it’s doing the condition 2 times, first result... (5 Replies)
Discussion started by: Shenbaga.d
5 Replies

7. Shell Programming and Scripting

Check first column - average second column based on a condition

Hi, My input file Gene1 1 Gene1 2 Gene1 3 Gene1 0 Gene2 0 Gene2 0 Gene2 4 Gene2 8 Gene3 9 Gene3 9 Gene4 0 Condition: If the first column matches, then look in the second column. If there is a value of zero in the second column, then don't consider that record while averaging. ... (5 Replies)
Discussion started by: jacobs.smith
5 Replies

8. Shell Programming and Scripting

Match first two columns and calculate percent of average in third column

I have the need to match the first two columns and when they match, calculate the percent of average for the third columns. The following awk script does not give me the expected results. awk 'NR==FNR {T=$3; next} $1,$2 in T {P=T/$3*100; printf "%s %s %.0f\n", $1, $2, (P>=0)?P:-P}' diff.file... (1 Reply)
Discussion started by: ncwxpanther
1 Replies

9. Shell Programming and Scripting

Taking nth column and putting its value in n+1 column using awk

Hello Members, Need your expert opinion how to tackle below. I have an input file that looks like below: USS|AWCC|AFGAW|93|70 USSAA|Roshan TDCA|AFGTD|93|72,79 ALB|Vodafone|ALBVF|355|69 ALGEE|Wataniya (Nedjma)|DZAWT|213|50,550 I like output file in below format: ... (7 Replies)
Discussion started by: umarsatti
7 Replies

10. UNIX for Beginners Questions & Answers

Average of columns

I have files that have the following columns chr pos ref alt sample 1 sample 2 sample 3 chr2 179644035 G A 1,107 0,1 58,67 chr7 151945167 G T 142,101 100,200 500,700 chr13 31789169 CTT CT,C 6,37,8 0,0,0 15,46,89 chr22 ... (3 Replies)
Discussion started by: nans
3 Replies
GSLP(1) 							    Ghostscript 							   GSLP(1)

NAME
gslp - Format and print text using ghostscript gsbj - Format and print text for BubbleJet printer using ghostscript gsdj - Format and print text for DeskJet printer using ghostscript gsdj500 - Format and print text for DeskJet 500 BubbleJet using ghostscript gslj - Format and print text for LaserJet printer using ghostscript SYNOPSIS
gslp -12BclqRr -b<header> -f<font> -F<hfont> -L<lines> -p<outfile> -T<n> --add-to-space <units> --add-to-width <units> --columns <n> --detect --first-page <n> --kern <file.afm> --last-page <n> --(heading|footing)-(left|center|right) <string> --margin-(top|bot- tom|left|right) <inches> --no-eject-(file|formfeed) --spacing <n> [gs options] [files] gsbj [options] [files] gsdj [options] [files] gsdj500 [options] [files] gslj [options] [files] DESCRIPTION
This utility provides functionality approximately equivalent to the Unix enscript(1) program. It prints plain text files using a single font. It currently handles tabs and formfeeds, but not backspaces. It will line-wrap when using fixed-pitch fonts. It will also do kern- ing and width adjustment. The default device (-sDEVICE=) and resolution (-r) are as follows: gslp epson 180 gsbj bj10e 180 gsdj deskjet 300 gsdj500 djet500 300 gslj laserjet 300 By default the current date is formatted as the center header. OPTIONS
Standard switches implemented: -12BclqRr -b<header> -f<font> -F<hfont> -L<lines> -p<outfile> Sun switches implemented: -T<n> set tab width Switches ignored: -GghKkmow -# -C -d -J -n -P -S -s -t -v Switches added: --add-to-space <units> add the given number of 1/72" units to the width of each space (may be negative) --add-to-width <units> add the given number of 1/72" units to the width of each character (may be negative) --columns <n> print in <n> columns --detect treat the file as PostScript if it starts with %! --first-page <n> start printing at page <n> --kern <file.afm> kern using information from the given .AFM file --last-page <n> stop printing after page <n> --(heading|footing)-(left|center|right) <string> set the heading/footing fields; use -B first to clear --margin-(top|bottom|left|right) <inches> set a margin --no-eject-(file|formfeed) end-of-file/FF only starts a new column, not a new sheet --spacing <n> use double (n=2), triple (n=3), etc. spacing Also, the string %# in a heading or footing is replaced with the page #. SEE ALSO
gs(1) VERSION
This document was last revised for Ghostscript version 8.63. AUTHOR
Artifex Software, Inc. are the primary maintainers of Ghostscript. This manpage by George Ferguson. 8.63 1 August 2008 GSLP(1)
All times are GMT -4. The time now is 10:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy