Sponsored Content
Full Discussion: Computing data in awk
Top Forums Shell Programming and Scripting Computing data in awk Post 302352431 by ubeejani on Friday 11th of September 2009 10:09:16 AM
Old 09-11-2009
ripat! thanks for the correction.I was in hurry. Smilie
For each of the ID I want the following output:

L1[sade]=(resi * 0.21)+ (resj * 0.67) where resi =23/89 and resj =66/89
L2[sade]=(resi * 0.45)+ (resj * 0.49)

L1[foly]=( resi * 0.31)+ (resj * 0.30) where resi =43/99 and resj =56/99
L2[foly]=( resi * 0.34)+ (resj * 0.20)

L1[jude]=( resi * 0.40)+ (resj * 0.53) where resi =63/97 and resj =34/97
L2[jude]=( resi * 0.11)+ (resj * 0.32)

I hope you got the logic.
Thanks a lot.
Regards,
Ubee

---------- Post updated at 04:09 PM ---------- Previous update was at 03:23 PM ----------

cfajohnson !
In this code you didn't consider the value of "res" which is for "sade, res=23/89 and 66/89". Similarly for jude and foly. Please check my last message. I hope you will get my point.
Thank you.
Quote:
Originally Posted by cfajohnson

Code:
awk '{
 v1[$1] += $1
 v2[$1] += $2
 v3[$1] += $3
}
END {
for ( x in v1 )
  print x, v1[x], v3[x], v3[x] 
}' "$file"

 

8 More Discussions You Might Find Interesting

1. Cybersecurity

Trusted Computing

About a year ago, a friend of mine who worked on the OReilly Snort book took a propsal he and I had worked on for a book on Trusted Computing. Though the editor thought the content was good and worthwhile, he felt that there wasn't enough of a market to justify printing such a work. How many... (0 Replies)
Discussion started by: kduffin
0 Replies

2. Virtualization and Cloud Computing

Event Cloud Computing - IBM Turning Data Centers Into ?Computing Cloud?

Tim Bass Thu, 15 Nov 2007 23:55:07 +0000 *I predict we may experience less*debates*on the use of the term “event cloud”*related to*CEP in the future, now that both IBM and Google* have made announcements about “cloud computing” and “computing cloud”, IBM Turning Data Centers Into ‘Computing... (0 Replies)
Discussion started by: Linux Bot
0 Replies

3. Virtualization and Cloud Computing

Cloud Enabling Computing for the Next Generation Data Center

Hear how the changing needs of massive scale-out computing is driving a transfomation in technology and learn how HP is supporting this new evolution of the web. More... (1 Reply)
Discussion started by: Linux Bot
1 Replies

4. Shell Programming and Scripting

AWK help. how to compare a variable with a data array in AWK?

Hi all, i have a data array as follows. array=ertfgj2345 array=456ttygkd . . . array=errdjt3235 so number or elements in the array can varies depending on how big the data input is. now i have a variable, and it is $1 (there are $2, $3 and so on, i am only interested in $1). ... (9 Replies)
Discussion started by: usustarr
9 Replies

5. Shell Programming and Scripting

Computing the ratio of similar columns in the two files using awk script

Thanks Bartus11 for your help in the following code to compare the two files "t1" and "t2". awk 'NR==FNR{a=1;next}$2 in a{print $2}' t1 t2 First can anyone explain that what is the purpose of assigning a =1? Second, the current script is printing out the matched columns between the... (4 Replies)
Discussion started by: coder83
4 Replies

6. Shell Programming and Scripting

Help with parsing data with awk , eliminating unwanted data

Experts , Below is the data: --- Physical volumes --- PV Name /dev/dsk/c1t2d0 VG Name /dev/vg00 PV Status available Allocatable yes VGDA 2 Cur LV 8 PE Size (Mbytes) 8 Total PE 4350 Free PE 2036 Allocated PE 2314 Stale PE 0 IO Timeout (Seconds) default --- Physical volumes ---... (5 Replies)
Discussion started by: rveri
5 Replies

7. UNIX for Dummies Questions & Answers

Computing for linearly-interpolated values using awk

Hi, I want to compute for linearly-interpolated values for my data using awk, any help is highly appreciated. How do I apply the linear interpolation formula to my data in awk given the equation below: x y 15 0 25 0.1633611 35 0.0741623 desired output: linear interpolation at... (4 Replies)
Discussion started by: ida1215
4 Replies

8. Shell Programming and Scripting

awk --> math-operation in data-record and joining with second file data

Hi! I have a pretty complex job - at least for me! i have two csv-files with meassurement-data: fileA ...... (2 Replies)
Discussion started by: IMPe
2 Replies
ADDLORES(3)						       MBK LOGICAL FUNCTIONS						       ADDLORES(3)

NAME
addlores - create a logical resistor ORIGIN
This software belongs to the ALLIANCE CAD SYSTEM developed by the ASIM team at LIP6 laboratory of Universite Pierre et Marie CURIE, in Paris, France. Web : http://asim.lip6.fr/recherche/alliance/ E-mail : alliance-users@asim.lip6.fr SYNOPSYS
#include "mlo.h" lores_list *addlores(ptfig,type,resi,rcon1,rcon2,name) lofig_list *ptfig ; char type ; double resi ; losig_list *rcon1, *rcon2 ; const char *name ; PARAMETERS
ptfig Pointer to the figure in which the resistor should be added type Resistor type resi Resistor value in Ohms rcon1 Pointer to the signal to be connected on the resistor top plate rcon2 Pointer to the signal to be connected on the resistor bottom plate name Resistor instance name DESCRIPTION
addlores creates a new resistor, and adds it to the list of resistors pointed to by ptfig -> LORES. The new resistor is added in front of the list, and becomes itself the list head. The type parameter can take one value : RESMIM for a metal resistor The resi argument is the resistor value in Ohms. Two connectors are created each time a resistor is added, and the rcon1 and rcon2 losigs are attached to the SIG field of the locon of the appropriate connector. The connectors names are rcon1 and rcon2; their direction, DIR, are set to 'R', and their TYPE INTERNAL. For details on the structures, see locon(3) and lores(3). RETURN VALUE
addlores returns a pointer to the newly created resistor. ERRORS
"*** mbk error *** illegal resistor type : type" The type is not a legal resistor type. EXAMPLE
#include "mlo.h" void parallel_resistors(void) /* netlist of two parallel resistors */ { lofig_list *pt = NULL ; losig_list *in = NULL ; losig_list *out = NULL ; pt = addlofig("parallel_resistors") ; addlocon(pt,"in",in = givelosig(pt,0),IN) ; addlocon(pt,"out",out = givelosig(pt,1),OUT) ; addlores(pt,RESMIM,0.2e-6,in,out,"res1") ; addlores(pt,RESMIM,0.2e-6,in,out,"res2") ; } SEE ALSO
mbk(1), lofig(3), lores(3), locon(3), dellores(3). BUG REPORT
This tool is under development at the ASIM department of the LIP6 laboratory. We need your feedback to improve documentation and tools. ASIM
/LIP6 August 14, 2002 ADDLORES(3)
All times are GMT -4. The time now is 03:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy