Bonus questions for Lab1

Please attempt these tasks only after completing lab1.

These questions are for your practice only! You will not receive any extra credit for this exercise. However, these are good questions for you to practice shell scripting and will help you do better in the exams.


Task 1

In your lab1, you are given a list of keywords as an argument. For this task, you have to make sure that if a word given in the list of keywords is repeated, then your program must ignore the word. In other words, if a keyword has already been read and the line numbers are printed out, it must not perform the same task again. For example, if the list of keywords is "Computer Science Computer", then it must ignore the second "Computer" since it has already seen the word before.

Task 2

This task asks you to print out the list of files and the corresponding line number sorted in the descending order of the number of times it has appeared in a particular file. For example, if the keyword "Chocolates" has appeared in three files namely, "Hersheys" 10 times, "Galaxy" 15 times and "Godiva" 5 times. The list should be printed out in the following order: Galaxy, Hersheys, Godiva. The printing format, however, is still the same as given in the lab1 description.