Write an AWK program

Write an AWK program which takes the following input _le and processes it.

$cat data.txt

John Do 111-1111 English 90 Maths 80

Alice Do 222-2222 English 90 Maths 90 Chemistry 93

The input _le has _rst 3 _elds _xed as _rst name, last name, and student id. After the student id, it has

a variable number of _elds which has a pair of name of a subject and points scored in that subject.

Your output should print the full name of the student, number of subjects taken, and his/her average

score. The output corresponding the above input _le is as follows:

$awk -f avgerage.awk data.txt

John Do: 2 subjects taken, average = 85

Alice Do: 3 subjects taken, average = 91

2.     Write a BASH/C shell script which takes a name of a directory as a command line

argument, and prints unique login name of the users having _les in that directory. Your code should

perform appropriate error checking.

A sample output is:

$sh name.sh /etc

mysql news root uucp

3.     Write a BASH/C shell script which takes name of one or more _les as a command line

argument, and prints the following information for each _le: owner, number of words in the _le, last

update time of the _le. Your code should have appropriate error checking.

 

The sample output is as follows:

$sh final.sh file1.txt file2.txt

file1.txt : ssaha : 25 : 2011-21-04 17:47

file2.txt : jliu : 16 : 2011-21-04 18:36

4.     Write a PERL script which takes a _le named input.txt as an input and processes it. The

input _le has the following format: _rstname lastname: pass/fail score%.

A sample input _le is:

$cat input.txt

John Do: pass 59%

Alice Do: fail 30%

Bob Do: PASS 80%

 

If the user has passed (i.e. has case insensitive \pass" in the 3rd _eld), then your code should print the

login name (_rst letter of _rst name followed by the last name, all in lowercase) of the user and his/her

corresponding score in fraction.

The output of your code on the above input should look like:

$perl final.pl

jdo: 0.59

bdo: 0.8

   Related Questions in Science

©TutorsGlobe All rights reserved 2022-2023.