Sponsored Content
Top Forums Shell Programming and Scripting awk-calculate records of a text Post 302428998 by Mark_orig on Saturday 12th of June 2010 09:05:10 AM
Old 06-12-2010
Smilie You are genius ! Smilie

---------- Post updated 06-12-10 at 01:05 PM ---------- Previous update was 06-11-10 at 04:38 PM ----------

And how to find the total cost per year ? 2007, 2008, 2009 etc ?

Code:
awk '/^TK/{print $2,$3;c+=$5}{a[$7]+=$5}END{print "Total cost for TK is "c;for (i in a){print i, " total cost per model "a[i]}}' cars.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to calculate a sum of certain records?

Hi, i have a file where the records are like this. vt100 2048 D402 MG0010 0 586 262144 D403 MG0011 1000 486 8192 D404 MG0012 270 386 8192 A423 CC0177 40 586 65536 A424 CC0182 670 486 16384 A423 CC0183 100 486 16384 A425 CC0184 80 65000 4096 B407 EE1027 80 I want firstly, to count how... (10 Replies)
Discussion started by: sickboy
10 Replies

2. Shell Programming and Scripting

How to calculate with awk

Hi, I have below awk statement and I need to convert the second field ( substr($0,8,6))from minutes to hours with 2 decimail place. How can I achieve this? /usr/bin/awk '{print substr($0,23,4),substr($0,8,6)}' /tmp/MANAGER_LIST.$$ >> /tmp/NEWMANAGER_LIST.$$ Thanks for any help! (4 Replies)
Discussion started by: whatisthis
4 Replies

3. UNIX for Dummies Questions & Answers

Use awk to calculate average of column 3

Suppose I have 500 files in a directory and I need to Use awk to calculate average of column 3 for each of the file, how would I do that? (6 Replies)
Discussion started by: grossgermany
6 Replies

4. Shell Programming and Scripting

How to findDuplicate Records in a text file

Pls Any one help me in (2 Replies)
Discussion started by: G.Aavudai
2 Replies

5. Shell Programming and Scripting

how can i calculate a file using awk

hi all Am new to scripting... So,i have a file named file1 its contents are as follows: joy 55 66 77 ruby 77 88 99 saloni 88 44 33 I would require a script which will calculate its percentage,its total and the average with awk script Many thanks in advance.. Please reply me at... (4 Replies)
Discussion started by: whizkidash
4 Replies

6. Shell Programming and Scripting

awk script to calculate total

Hi First field is the Record Type. A Record Type 5 can have multiple Record Type 6's before another Record Type 5 appears. I want to calculate the total of fields at position 8-11 on Record type 6 when Record Type 5 has a field at position 11-14 equals to '2222'. then it should delete the lines... (2 Replies)
Discussion started by: appsguy616
2 Replies

7. Shell Programming and Scripting

Calculate P Value -Awk

Is there any awk command to calculate P Value ?(Probability) Is it possib;e to calculate P va;ue for this data for ex? 7.891284 8.148193 7.749575 7.958188 7.887702 7.714877 8.141548 7.51845 8.27736 7.929853 7.92456 8.249126 7.989113 8.012573 8.351206 (2 Replies)
Discussion started by: stateperl
2 Replies

8. Shell Programming and Scripting

Using AWK to Calculate Correct Responses

Hello, I am trying to count how many times a subject makes a correct switch or a correct stay response in a simple task. I have data on which condition they were in (here, labeled "IMAGINE" and "RECALL"), as well as whether they made a left or right button response, and whether the outcome was... (5 Replies)
Discussion started by: Jahn
5 Replies

9. Shell Programming and Scripting

Calculate Average AWK

I want to calculate the average line by line of some files with several lines on them, the files are identical, just want to average the 3rd columns of those files.:wall: Example file: File 1 001 0.046 0.667267 001 0.047 0.672028 001 0.048 0.656025 001 0.049 ... (2 Replies)
Discussion started by: AriasFco
2 Replies

10. UNIX Desktop Questions & Answers

Calculate average for rows in a text file

Dear Gurus, I have tab-delimited text files with matrix containing values. The first column is a identifier and other columns have the corresponding values. I would like to calculate the average value (total number/number of entries) for all entries from 2nd column to the last column in row... (3 Replies)
Discussion started by: Unilearn
3 Replies
happrox(1)						  GNU Triangulated Surface utils						happrox(1)

NAME
happrox - returns a simplified triangulation of a set of points using algorithm III of Garland and Heckbert (1995). SYNOPSIS
happrox [OPTIONS] < [input.pgm|input] > output.gts DESCRIPTION
This manual page documents briefly the happrox command. OPTIONS
This program follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. -n N, --number=N Stop the refinement process if the number of vertices is larger than N. -c C, --cost=C Stop the refinement process if the cost of insertion of a vertex is smaller than C. -f, --flat Input is a flat file with three x,y,z columns (default is PGM file). -r Z, --relative=Z Use relative height cost for all heights larger than Z. -k, --keep Keep enclosing triangle. -C, --closed Close the surface. -l, --log Log evolution of cost. -v, --verbose Display surface statistics. -h, --help Display the help and exit. AUTHOR
happrox was written by Stephane Popinet <popinet@users.sourceforge.net>. This manual page was written by Ruben Molina <rmolina@udea.edu.co>, for the Debian project (but may be used by others). June 2, 2008 happrox(1)
All times are GMT -4. The time now is 03:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy