12/27/2023 0 Comments Bash grep all directories![]() ![]() Change “ grep -iH” to “ grep -ic” ( c for count, H to return filename for each match, and i to ignore case). If you would like to only count the number of error. Initially called countProd.sh because I was using it to count the number of certain errors. –> View file here without comments–> countProd.txt Grep -iH “$word” $locationAlpha $locationBravo $locationCharlie $locationDelta $locationEcho $locationFoxtrot $locationGulf Read -p “Enter the word you want to find: ” word # returns word you enteredĮcho “Searching for ‘$word'” #Starts searching and returning hits LocationGulf=”/LOGS/Websphere-07/General.log”# Next line will prompt for the word or phrase you want to search The output should look something like this: root:x:0:0:root:/root:/bin/bash linuxize:x:1000:1000:linuxize:/home/linuxize:/bin/bash. LocationFoxtrot=”/LOGS/Websphere-06General.log” This will make grep look recursively (-r option) and provide the result in a human-readable format (-H option) for the string database in all () files under. LocationEcho=”/LOGS/Websphere-05/General.log” LocationDelta=”/LOGS/Websphere-04/General.log” LocationCharlie=”/LOGS/Websphere-03/General.log” LocationBravo=”/LOGS/Websphere-02/General.log” ![]() LocationAlpha=”/LOGS/Websphere-01/General.log” #!/bin/bash# First add the directories you want to search In the past, I have used it to search dozens of logs in production at the same time for errors. 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. This is a Command Line Interface (CLI) Shell script that once set up using the directories you want to search. Audience that may find this useful will mostly be new Linux administrators.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |