![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Sorting your data with msort | iBot | UNIX and Linux RSS News | 0 | 05-19-2008 11:20 AM |
| Sorting data and place them in different folders | Vinaykumar1 | UNIX for Dummies Questions & Answers | 29 | 05-14-2008 08:47 AM |
| sorting data using array in ksh | ali560045 | Shell Programming and Scripting | 4 | 12-04-2007 04:26 AM |
| Sorting blocks of data | alfredo123 | Shell Programming and Scripting | 8 | 07-05-2007 10:53 AM |
| sorting data based on multi columns | sumeet | UNIX for Advanced & Expert Users | 2 | 02-15-2007 12:57 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi guys, just started using awk here.
I've got a file called a.txt which contains a load of numbers on each line e.g. 35 232 654 1 9 4 I want to learn how to do three things: 1. Find the minimum 2. Find the maximum 3. Find the average I want to learn how to do this using awk. Pretty basic stuff I should think but all I'm new to this so help please. |
|
||||
|
Quote:
|
|
||||
|
one way find min
Code:
awk 'NR==1 { temp = $1 ;next}
{ if ( $1 <= temp ) { temp=$1 } }
END{ print temp}' "file"
find avg Code:
awk 'BEGIN{count=0}
{ count = count + $1}
END{ print count/NR}' "file"
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|