The UNIX and Linux Forums  

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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 08-27-2007
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Bangalore
Posts: 219
Try this:


Code:
awk -v INPUT=$INPUT '
BEGIN { ORS=""}
{

print $0 " "
if (( NR % INPUT ) == 0) {
print "\n"
count++
}

if (( NR % INPUT ) == 1) 
sum += $0

}

END { 
 op = sum/count
print op }' Filename