Starting from:

$25

CS213- Lab 11 Solved

 

CS213: Software Systems Lab

Lab 11 – Awk Programming

We have five questions in this Lab 11.

  

-------------------------------------------------------------------  Question 1:  Write an awk program using 'arrays' which takes an input file having some numbers in each record. Assume that each record has same number of fields. Then write rows as columns and columns as rows.

 

For example :

 input :  1 2 3  

4 5 6

7 8 9

 

Output :  

1  4 7

2  5 6

3  6 9

  

-------------------------------------------------------------------  Question 2:   

 

Write an awk script to do matrix multiplication.  

It takes as input two matrices from two files "matrix1" and "matrix2" and gives output in "matrix3", if the multiplication is possible otherwise states that it is not possible giving out reasons.  

  

  

-------------------------------------------------------------------  Question 3:   

  

Write an 'AWK' script and not a shell script which interactively asks the user to enter a number and outputs it only once in Roman numerals,  if the number is within 1 and 10.  

 

Given below is an expected behaviour:

 on input : 4   Output : IV on input : 10  Output : X on input : 4   Output : "Given previously".

on input : q   Program terminates.  

  

Hint: Use array, split, deleting an array element

 

-------------------------------------------------------------------  Question 4:   

Write an 'AWK' script and not a 'shell' script which outputs values   of "PATH" environment variables.

  

-------------------------------------------------------------------  

Question 5:  

  

Write an 'AWK' script which reads text file and changes each line to also write the number of characters in each field.

It should not count punctuation marks.

 

For example the input line   

"For instance, if you match"   

 is changed to the following:

"For instance, if you match 3 8 2 3 5"   

 

-------------------------------------------------------------------  

 

More products