awk question


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk question
# 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

Ex.

Code:
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 09: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 for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #367
Difficulty: Medium
The Single UNIX Specification specifies vi, so every conforming UNIX system must have it.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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, (5 Replies)
Discussion started by: rveri
5 Replies

2. Shell Programming and Scripting

question about awk

given this: # ls -1 /dev/sd /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf returns a list of devices I want to use as input for some other operations. So ... # ls -1 /dev/sd | awk '{FS="/"; print $3 }' sdc sdd sde sdf # Where I should get sdb, I get a blank line ...... (4 Replies)
Discussion started by: edstevens
4 Replies

3. Shell Programming and Scripting

Another awk question

Hello I'm (another) newbie in bash scripting (my second day). I'm trying to locate a phrase in a number of files (multiple files in subdirectories) replace this phrase with another one and produce an output that contains the filename of the search string occurrence, the row in that file... (4 Replies)
Discussion started by: pavlosgr
4 Replies

4. Shell Programming and Scripting

AWK question

Hi. I have a problem whit a script AWK. I need erase the last position of one file. What to do? (5 Replies)
Discussion started by: tvi_fpolis
5 Replies

5. UNIX for Dummies Questions & Answers

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 test.sh awk '{print $1}' From the prompt if I enter: ./test.sh Hello World I would expect to see "Hello" but all I get is a blank line. Only then if I enter "Hello... (2 Replies)
Discussion started by: JasonHamm
2 Replies

6. Shell Programming and Scripting

awk question

For the following code: ps auwx | awk -v "PID=${PID}" '$2 == PID {print $LN}' Two points to clarify: 1. Is the -v flag for declaring we're going to work with a variable? 2. Does the $LN stands for current line? If so, what's wrong with $0? Any difference between them? Thanks (6 Replies)
Discussion started by: ynir
6 Replies

7. Shell Programming and Scripting

an awk question

i hav input as sec_dav_table varchar(18) sec _dac2_table date(2) Can anyone help me in helping out in a awk to get d desired output as Table starting size primary key sec_dav_ table 1 18 T sec _dac2_table 19 ... (1 Reply)
Discussion started by: gopimeklord
1 Replies

8. Shell Programming and Scripting

Question in awk

Dear All, How can we sort using awk?Is there anything by default Please help me. Regards, Sukumar (4 Replies)
Discussion started by: jerome Sukumar
4 Replies

9. Shell Programming and Scripting

AWK question

I have file "A" containing keywords as sequential records. For each key word in file "A", 1. need to find the files hat contained the keyword in a given directory 2. Find the file name that contained the first occurance of the keyword 3. Print the record that contatined the first occurance of... (1 Reply)
Discussion started by: ucbus
1 Replies

10. UNIX for Dummies Questions & Answers

Question on AWK

Does anyone know if we can use AWK to list out the fields which don't have a delimiter, i.e., cut out fields say 2 and 10 in a fixed width data. I tried to use FIELDWIDTHS in awk but that is not helping me out. Or Can we use cut commands to cut out couple of fields which are fixed width data... (2 Replies)
Discussion started by: Aceform
2 Replies