This is a Command Line Interface (CLI) Shell script that once set up using the directories you want to search. All you will have to do is enter the word or phrase that you are trying to search and it will search across the directories (if you use *) and files for the key word/phrase.
In the past, I have used it to search dozens of logs in production at the same time for errors.#!/bin/bash### First add the directories you want to search
locationGulf=”/LOGS/Websphere-07/General.log”### Next line will prompt for the word or phrase you want to search
read -p “Enter the word you want to find: ” word ## returns word you entered
echo “Searching for ‘$word'” ##Starts searching and returning hits
grep -iH “$word” $locationAlpha $locationBravo $locationCharlie $locationDelta $locationEcho $locationFoxtrot $locationGulf
–> View file here without comments–> countProd.txt
Initially called countProd.sh because I was using it to count the number of certain errors. If you would like to only count the number of error. Change “grep -iH” to “grep -ic” (c for count, H to return filename for each match, and i to ignore case) .
That’s it, short and simple.