Explore BrainMass

Explore BrainMass

    Unix shell script: text file with most occurrences of string

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    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)

    © BrainMass Inc. brainmass.com December 24, 2021, 8:42 pm ad1c9bdddf
    https://brainmass.com/computer-science/files/unix-shell-script-text-file-most-occurrences-string-304784

    Solution Preview

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

    Solution Summary

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

    $2.49

    ADVERTISEMENT