Purchase Solution

Unix shell script: text file with most occurrences of string

Not what you're looking for?

Ask Custom Question

Create a Unix shell script that searches for a text file with most occurrences of a given keyword. For instance, if I would like to search for a script with most usages of if statement, I would execute:

find_most_relevant.sh /home/student/myscripts if

The script find_most_relevant.sh should take two arguments. The first one is the directory where text files are located. The second argument is a keyword. The output of the script should either state:

No file with word <keyword> found in the directory <directory-name>

Or

file <filename>: found X occurrences of word <keyword>

(for the file with most occurrences of keyword only)

Purchase this Solution

Solution Summary

Attached Bash script recursively searches the given directory for the given keyword is examined.

Solution Preview

Please find attached a Bash script (304784_find_most_relevant.sh) that recursively searches ...

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Basic Networking Questions

This quiz consists of some basic networking questions.