awk question

Login or Register to Reply

Thread Tools Search this Thread
# 1  
awk question

I have a data set that has 9 columns (Name, Type, Score).
here's a sample name=name, Type = Q(for quiz) - E(for exams) - H(for Homework) - F(for final), Score = 90.
I can easily add up all my scores then divide them for average or mean (total/n). How do I assign the value to corresponding letter in an Array


Name   Type   Score   Type   Score   Type   Score   Type   Score
Jones     Q        90       H        100     E        74        F        75
Bob          q         80      H        70       e        88        f        77

if I want to ad all the digits after Q (like 90 and 80) to get the average, how would I throw them in an array to get the mean?

Last edited by Don Cragun; 02-25-2016 at 07:58 PM.. Reason: Add CODE tags.
# 2  
Is this a homework assignment? Homework and coursework questions can only be posted in the Homework & Coursework forum following the requirements specified in the special homework rules.

If you did post homework in the main forums, please review the guidelines for posting homework and repost in the correct sub-forum and include a completely filled out homework template. Otherwise, please explain what real problem you are trying to solve here.

Show us what code you have tried to solve your problem (in CODE tags) and show us the output you are trying to produce (also in CODE tags) from the sample input you have provided.
Login or Register to Reply

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
awk question : system output to awk variable.
Hi Experts, I am trying to get system output to capture inside awk , but not working: Please advise if this is possible : I am trying something like this but not working, the output is coming wrong: echo "" | awk '{d=system ("date") ; print "Current date is:" , d }' Thanks,... Shell Programming and Scripting
Shell Programming and Scripting
awk question
Hi guys, I am using the following 'awk' command to check for the number of fields in my input entry and print 555 if the entry does not contain 2 fields: $time="12:33" $echo $time | awk '{FS=":"; if (NF!=2) print 555}' $555 For some reason the command always prints 555 no matter how many...... Shell Programming and Scripting
Shell Programming and Scripting
Basic awk question...getting awk to act on $1 of the command itself
I have a script problem that I am not able to solve due my very limited understanding of unix/awk. This is the contents of awk '{print $1}' From the prompt if I enter: ./ Hello World I would expect to see "Hello" but all I get is a blank line. Only then if I enter "Hello...... UNIX for Dummies Questions & Answers
UNIX for Dummies Questions & Answers
awk question
Hi, I trying my first awk script. I have this: my code file: #!/usr/bin/ksh BEGIN{FS=","} {if(FILENAME=="indata.txt") {L=1}} END{print $1","$2","$3","L","$0} my example file: 1,2v3,4,5 #,2,3,4,5,6,78,9 i got this error:... Shell Programming and Scripting
Shell Programming and Scripting
awk question
new to this..thanks in advance for unix (awk) help... I have a large file of 3 fields, all numeric, not decimal 8, 8 and 12 bytes; the 1st field is a unique identifier which may be repeated in the file from lines 2-n; the 2nd and 3rd fields contain info about field #1. I want to concatenate the...... UNIX for Dummies Questions & Answers
UNIX for Dummies Questions & Answers