CS213 Assignment 11-Awk Programming Solved

30.00 $

Category:

Description

5/5 - (1 vote)
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 : 123 456 789

Output : 147 256 369

——————————————————————- 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 oninput:10 on input : 4 on input : q

Output : IV
Output:X
Output : “Given previously”. 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"

——————————————————————-

  • Assignment-11-9ghmbb.zip