The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Average in awk saint2006 Shell Programming and Scripting 6 06-19-2008 03:09 PM
how to average in awk saint2006 Shell Programming and Scripting 4 06-04-2008 12:29 PM
Average Time sambond UNIX for Dummies Questions & Answers 1 01-16-2008 10:57 AM
Low average cpu utilization. Moodie SUN Solaris 3 12-11-2007 07:25 PM
average value su_in99 UNIX for Dummies Questions & Answers 2 03-10-2007 01:41 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-12-2009
riderman riderman is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 12
get min, max and average value

hi!
i have a file like the attachement.
I'd like to get for each line the min, max and average values. (there is 255 values for each line)
how can i get that ?
i try this, is it right?


Code:
BEGIN {FS = ","; OFS = ";";max=0;min=0;moy=0;total=0;freq=890}

$0  !~ /Trace1:/ {
        
        max=min=moy=total=$1
        for (i=2;i<=NF;i++)
            { if ($i>max) {max=$i}
              if ($i<min) {min=$i}
              total=total+$i
            }
        
        print freq,min,max,total/255    
        freq=freq+0,202    
                    
        }
                    
                            
     
END       {}

Attached Files
File Type: zip File_1.zip (1.96 MB, 23 views)
  #2 (permalink)  
Old 02-12-2009
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,934

Code:
BEGIN {FS = ","; OFS=";"; freq=890}

$0  !~ /Trace1:/ {

   max=min=total=$1
   for (i=2; i <= NF; i++) {
      if ($i > max) max=$i
      if ($i < min) min=$i
      total += $i
   }

   print freq, min, max, total/255

   freq += 0.202
}

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:53 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0