divide with awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting divide with awk
# 1  
Old 10-09-2006
divide with awk

Dear,

i want to devide the first 4 values from a raw over the next 4 values like the following:

$1+$2+$3+$4 / $5+$6+$7+$8

using AWK ....can someone help me?

Sanks
# 2  
Old 10-09-2006
Code:
awk '{ tmp=($1+$2+$3+$4)/($5+$6+$7+$8) ; printf"%0.2f\n", tmp }' yourinputfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Divide the value of the column if not NULL.

File 1 --------- N_ACCT,CARD_TYPE,CARD_BAL,CUST_CODE --------------------------------------------------- 0301,38,0.00,10 0319,38,54422.92,10 0392,38,0.00,10 0418,38,35254.87,10 0442,38,0.00,10 0491,38,0.00,10 0558,38,45988.76,10 0616,38,0.00,10 0665,38,0.00,10 0699,38,0.00,10 File 2... (3 Replies)
Discussion started by: suresh_target
3 Replies

2. Shell Programming and Scripting

How to for awk print divide value more than 10000?

I have a text file with data in the following format. 042240.Thor!Loki: Asgard>Seus>/usr/Valhalla/Niflheim/Asgardianos/Seus.ec@266:Service Success => Diff time: 25689 msec, Energy loss = 212, Subr = 6969] 042240.Thor!Cap: Asgard>Hera>/usr/Valhalla/Niflheim/Asgardianos/Hera.ec@252:Begin call... (1 Reply)
Discussion started by: ooilinlove
1 Replies

3. UNIX for Dummies Questions & Answers

To divide file

We have large log files, and we need to extract last four hours lines only, Please let us know the command. Thanks, Saurau. (1 Reply)
Discussion started by: saurau
1 Replies

4. Shell Programming and Scripting

Divide by zero script

Hi, I've been working on a few scripts and have been getting great info. How, would I include in the below script, how I would let a user know that if they divide a SECOND number by zero, that they would get a divide by zero error? What's the easiest way of working this? Cordially, joe. ... (1 Reply)
Discussion started by: jefferj54
1 Replies

5. Shell Programming and Scripting

Divide two variable

F= `expr $E/$S` output test5.sh: line 45: 1296863.27001857757568359375/21997: No such file or directory can any one help me ,i just want to divide the $E/$S and Print o/p in F. (3 Replies)
Discussion started by: netdbaind
3 Replies

6. Shell Programming and Scripting

Divide variable

Hi All, here D Prints the bytes value .plz help to convert the variable D value to MB in new variable $E D=`more $C |awk '{print $6;}'` Thanks in Advance.:) (3 Replies)
Discussion started by: netdbaind
3 Replies

7. Shell Programming and Scripting

AWK print number of records, divide this number

I would like to print the number of records of 2 files, and divide the two numbers awk '{print NR}' file1 > output1 awk '{print NR}' file2 > output2 paste output1 output2 > output awl '{print $1/$2}' output > output_2 is there a faster way? (8 Replies)
Discussion started by: programmerc
8 Replies

8. Shell Programming and Scripting

awk count characters, sum, and divide by another column

Hi All, I am another biologist attempting to parse a large txt file containing several million lines like: tucosnp 56762 T Y 228 228 60 23 .CcCcc,,..c.c,cc,,.C... What I need to do is get the frequency of periods (.) plus commas (,) in column 9, and populate this number into another... (1 Reply)
Discussion started by: peromhc
1 Replies

9. UNIX for Dummies Questions & Answers

divide issue

Hi, I have a issue dividing 2 values in UNIX a=15 b=100 c = a / b ==> and it is returning 0 instead of 0.15 into variable C. How can i resolve this issue ? please help (1 Reply)
Discussion started by: kotasateesh
1 Replies

10. Shell Programming and Scripting

script needs to divide by 2

i need to divide this count by 2, what variable can i use in my script? 26 hcscprod_cpus_totals /2 = 13 13 hcncprod_cpus_totals /2= 6.5 541 ktazp_cpus_totals /2= 270.5 346 ktazd_cpus_totals /2=173 110 ktazi_cpus_totals /2=55 10 ktazq_cpus_totals /2=5 (2 Replies)
Discussion started by: wereyou
2 Replies
Login or Register to Ask a Question