Question on AWK Tool in Unix.

Question Bank
12.1 How can we make the AWK to respond case insensitive to case.
12.2 Suppose we create a phone directory of friends with family name, first name and phone number on each line. How shall we use AWK to determine which is the most commonly occurring family name in our phone directory?
12.3 Suppose in for the phone directory generated for question above, we additionally have a field city. How can be use AWK to get a count of friends in each city?
12.4 Suppose the tax deduction is done as follows:
a. If an employee has a salary of Rs. 5000/- p.m. or less the tax is not deducted
b. If the salary is between Rs. 5000/- and 10000/- p.m. and the age is over 55 years then also the tax is not deducted.
c. In the case the salary is higher than the “no-tax” limits as defined in a and
b above then the tax is deducted at 30% for the excess income for the first slab of Rs.10000/- and 40% of the remaining. How will you write an AWK program to process a file that has employee salary details.
12.5 For the program in question 4 write a pretty printing program to tabulate describing the tax deduction.
12.6 Indians have several spellings for "Ray", "Rae", "Rai", Roy" etc. Telephone directories often group family names with minor variations. Write the AWK command line if you were to filter records on the first field which happens to have the family names for the example family name which we have in this question.
Illustrate how you may obtain a sorted output using "sort" on the output from the "awk" program output.
12.7 Describe at least four built in variables in AWK and demonstrate their use giving an example for each.
12.8 Compare and contrast AWK with PERL.
12.9 Write a awk script that s will take an arbitrary stream of text (where paragraphs are indicated by consecutive \n) and make all the lines approximately the same length. The default output line length is 72, but it may be set via a parameter on Operating the awk command line. Both long and short lines are taken care of but extra spaces/tabs within the text.
12.10 Perform the following operations on a given file
a. Print the length of the longest input line:
b. Print every line that is longer than 80 characters:
c. Print the length of the longest line in data:
expand data | awk '{ if (x < length()) x = length() }
END {print "maximum line length is” x}'
d. Print every line that has at least one field:
e. Print the total number of kilobytes used by files:
12.11 Remove only the files ( not sub directories) in a given directory using awk
12.12 Write a command to count the number of lines in a file that do not contain any vowels.

Comments

Popular posts from this blog

Introduction to Operating Systems:Early History: The 1940s and 1950s

Input Output (IO) Management:HW/SW Interface and Management of Buffers.

Summary of Process Concepts